作者:赵月916_640 | 来源:互联网 | 2023-02-03 17:25
1> 小智..:
让我解决你的问题,伙计.
问题: 程序不显示输出.
原因:
程序执行需要几十秒才能显示输出和turbo c ++ compilor无法控制它.因此,编码人员有责任控制执行以显示输出.
解决方案:
1.使用 getch(); //it is predefined function of
2.使用getchar(); //it is predefined function of
运用 getch();
码:
#include
#include
int main()
{
printf("Hello world\n");
getch(); //it can be used to hold program execution,it wait until the user enters a character.
return 0;
}
使用 getchar();
码:
#include
int main()
{
printf("Hello world\n");
getchar(); //getchar() means get a character from user,if user press any key + enter then getchar() executes.
return 0;
}