How do i enter an EOF character in this program?

本小妞迷上赌 提交于 2019-12-14 03:31:07

问题


i was studying EOF character in c and came across a program :

#include <stdio.h>
main()
{
int c= 0;
while((c = getchar())!=EOF)
putchar(c);
}

its all good it is giving proper o/p but how do i come out of the loop by entering a EOF character which i entered and it did nothing.


回答1:


To stimulate EOF in stdin,

  • If you are on windows or DOS press CTRL+Z
  • Or if you are running linux or some other OS, press CTRL+D



回答2:


I dont think there is an EOF character,and CTRL+Z and CTRL+D are used to inform the OS for termination. Follow these links it has the answers Representing EOF in C code? End of File (EOF) in C



来源:https://stackoverflow.com/questions/28380039/how-do-i-enter-an-eof-character-in-this-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!