Is there any limitation on string length defined in variable argument list

前端 未结 3 762
温柔的废话
温柔的废话 2021-01-26 00:11

I have doubt regarding variable argument list,is there any limitation on the lenght of char string defined as one of argument to variable list.for example

void S         


        
相关标签:
3条回答
  • 2021-01-26 00:38

    No.

    All that gets passed in the call is character pointers after all.

    The size of each pointer is constant, regardless of how many characters are in the string it points at.

    0 讨论(0)
  • 2021-01-26 00:54

    There is no limit imposed by the C language on how long a C string can be (as C strings are basically arrays of char with a NUL character at the end). As you can see, the type of the argument is char *, i.e., pointer to char. This means that the string itself is not passed as an argument, but rather a pointer to its first character—the length of the string is therefore irrelevant for the function call.

    (In practice there will of course be a limit from the computer architecture and platform, but these limits are very high compared to typical string arguments.)

    0 讨论(0)
  • 2021-01-26 00:58

    Theoretically No. The argument char * is just a pointer to the array of characters.

    0 讨论(0)
提交回复
热议问题