오늘 C 언어로 테스트하고 있었고, 난이 두 개의 작은 C 파일C 함수 호출 오류
main.c를
#include<conio.h>
void testing();
int main()
{
testing();
getch();
return 0;
}
testing.c
#include <stdio.h>
void testing()
{
char ch;
printf("Hello Testing\n");
do{
printf("Enter Character : ");
ch=getchar();
printf("You Entered : %c\n",ch);
testing();
}while(ch!='N');
}
내가 직면하고 문제를 만든 사용자로부터 한 문자를 읽은 다음 두 번 반복합니다. 이유를 모르겠습니다.
output
Hello Testing
Enter Character : k //(i entered k)
You Entered : k
Hello Testing// why this is displayed twice??
Enter Character : You Entered :// i don't press any key and it moves to next iteration
Hello Testing
Enter Character : // here i can enter character again and it happens again twice
Visual Studio 2012에서이를 준수했습니다.
감사합니다. :) 정말 많이 도움이되었습니다. – user1759804