program6_02.c
来自「C语言入门经典一书的所有代码。书上面的所有代码均在此。希望大家喜欢」· C语言 代码 · 共 19 行
C
19 行
/* Program 6.2 Lengths of strings */
#include <stdio.h>
int main(void)
{
char str1[] = "To be or not to be";
char str2[] = ",that is the question";
int count = 0; /* Stores the string length */
while (str1[count] != '\0') /* Increment count till we reach the string */
count++; /* terminating character. */
printf("\nThe length of the string \"%s\" is %d characters.", str1, count);
count = 0; /* Reset to zero for next string */
while (str2[count] != '\0') /* Count characters in second string */
count++;
printf("\nThe length of the string \"%s\" is %d characters.\n", str2, count);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?