我编写了以下代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 128
int main ()
{
char mychar , string [SIZE];
int i;
int const count =0 ;
printf ("Please enter your string: \n\n");
fgets (string, SIZE, stdin);
printf ("Please enter char to find: ");
mychar = getchar();
for (i=0 ; (string[i] == '\0') ; i++ )
if ( string[i] == mychar )
count++;
printf ("The char %c appears %d times" ,mychar ,count);
return 0;
}
问题是 gcc 给我一个关于“int const count”的错误:“只读变量“count”的增量”。
哪里出了问题?
谢谢!
最佳答案
关于c - C 中的 gets() 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5632239/