C Tutorial/String/String Length — различия между версиями

Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 13:32, 25 мая 2010

Lengths of strings

<source lang="cpp">#include <stdio.h> int main(void) {

 char str1[] = "AAA";

 int count = 0;                 
 while (str1[count] != "\0")    /* Increment count till we reach the string terminating character.*/
   count++;                     
   
 printf("\nThe length of the string \"%s\" is %d characters.", str1, count);
 return 0;

}</source>

The length of the string "AAA" is 3 characters.