请教各位大神:printf缓冲区刷新
windows + gcc程序代码:
void store2(){ int n; printf("enter max length of the word:"); scanf("%d",&n); char t[++n]; //printf("length %d",n); if(n>0){ printf("enter your line:"); char temp ; int index=0; //fflush(stdin); for(;;){ temp=getchar(); printf("%d",temp);// temp=10, 这里的换行符是从哪里来的? if(index == n || isspace(temp)){ t[index]='\0'; for(int i=0;i<=index;i++){ printf("%5d:%5d",index,t[index]); } break; } t[index] = temp; index++; } } fputs(t,stdout); }