Я только начинаю с C и пробую несколько примеров из книги Ритчи Я написал небольшую программу для понимания массивов символов, но наткнулся на несколько ошибок и надеялся получить некоторое представление о том, что я понял неправильно:
#include <stdio.h>
#define ARRAYSIZE 50
#include <string.h>
main () {
int c,i;
char letter[ARRAYSIZE];
i=0;
while ((c=getchar()) != EOF )
{
letter[i]=c;
i++;
}
letter[i]='\0';
printf("You entered %d characters\n",i);
printf("The word is ");
printf("%s\n",letter);
printf("The length of string is %d",strlen(letter));
printf("Splitting the string into chars..\n");
int j=0;
for (j=0;j++;(j<=strlen(letter)))
printf("The letter is %d\n",letter[j]);
}
Вывод:
$ ./a.out
hello how are youYou entered 17 characters
The word is hello how are you
The length of string is 17Splitting the string into chars..
Что происходит? разве цикл for не дает никакого результата?