내 주요 질문은 왜 fflush (stdin)입니까? 기능이 작동하지 않습니까? 코드를 실행할 때마다 두 번째 입력에 공백을 넣을 수 없습니다. 안녕하세요 세계 그러나 대신 나는여보세요 ?? 감사합니다fflush (stdin) 기능이 작동하지 않습니다.
#include <stdio.h>
main(){
int x;
double y;
char string[100];
/*
* string input
*/
printf("Enter one word: ");
scanf("%s", string); // note there is no & before string */
printf("The word you entered was >>%s<<\n");
printf("Enter many words: ");
fflush(stdin); // <---- for some reason this function is not working
scanf("%[^\n]", string); // read up to a newline (multiple words)
printf("The text you entered was >>%s<<\n");
getchar();
}
[플러싱 입력 스트림] (http://c-faq.com/stdio/stdinflush.html)을 참조하십시오. –
문제는'fflush (stdin)'과 아무 관련이 없습니다. 누락 된 매개 변수와 관련이 있습니다. 아래를 참조하십시오. (두 번째 매개 변수를 얻은 다음 형식 지정 작업을 할 수 있습니다) – ryyker