Why do I need to type Ctrl-D twice to mark end-of-file?

前端 未结 3 1870
再見小時候
再見小時候 2020-11-27 05:56
char **query; 
query = (char**) malloc ( sizeof(char*) );

int f=0;
int i=0,j=0,c;


while((c=getchar())!=EOF)
{      
    if(!isalpha(c))
        continue;

    if(         


        
3条回答
  •  情歌与酒
    2020-11-27 06:22

    In the off chance that someone sees this that needs the help I've been needing... I had been searching, trying to figure out why I was getting this strange behavior with my while(scanf). Well, it turns out that I had while (scanf("%s\n", string) > 0). The editor I am using (Atom) automatically put a "\n" in my scan, with out me noticing. This took me hours, and luckily someone pointed it out to me.

提交回复
热议问题