Update Index.md (#24095)
added clarification: strlen() does not include the null-termination characterpull/25227/head^2
parent
9a51e15850
commit
5606023aae
|
@ -178,7 +178,8 @@ strncat(char s1[], char s2[], int n);
|
|||
|
||||
#### Get length: `strlen`
|
||||
|
||||
`strlen` (from 'string length') will return an integer value corresponding to the length of the string. In this example, an integer called `string_length` will be assigned the length of `my_string`:
|
||||
`strlen` (from 'string length') will return an integer value corresponding to the length of the string. Even though all strings are terminated with a \0 character, it will not be included in the count (so the length "hello" is indeed 5 and not 6). In this example, an integer called `string_length` will be assigned the length of `my_string`:
|
||||
|
||||
```C
|
||||
string_length = strlen(my_string);
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue