How to get the real and total length of char * (char array)?

前端 未结 15 2544
小蘑菇
小蘑菇 2020-11-29 00:37

For a char [], I can easily get its length by:

char a[] = \"aaaaa\";
int length = sizeof(a)/sizeof(char); // length=6

However,

15条回答
  •  孤街浪徒
    2020-11-29 01:21

    Strlen command is working for me . You can try following code.

    // char *s

    unsigned int  strLength=strlen(s);
    

提交回复
热议问题