C Tutorial/String/String Length


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

Lengths of strings

#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;
}
The length of the string "AAA" is 3 characters.