내 주요 질문은 왜 fflush (stdin); 기능이 작동하지 않습니까? 코드를 실행할 때마다 공백으로 두 번째 입력을 얻을 수 없습니다. Hello World 대신 Hello ?? 감사
#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();
}
fflush(stdin)
정의되지 않은 동작 이기 때문 입니다. fflush()
출력 스트림 및 마지막 작업이 출력 인 업데이트 스트림에 대한 C 표준에 의해서만 정의됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다