当前位置: 代码迷 >> C语言 >> [求助]为什么要接收 回车符??
  详细解决方案

[求助]为什么要接收 回车符??

热度:168   发布时间:2006-05-13 08:00:00.0

谢谢版主.
#include "stdio.h"

int main (void)
{
char str;
FILE *fp;

if ((fp = fopen ("test.txt", "w")) == NULL)
{
printf (" can't create TXT file \n");
exit (0);
}

//str = getchar (); //在这个程式中终于搞清楚这两个和while loop中的str = getchar ();作用.
str = getchar ();

while ( str != '!')
{
if (str >= 'a' && str <= 'z')
str = str -32;

fputc (str, fp);
putchar (str);
str = getchar ();
}
fclose (fp);

getch ();
return 0;
}

[此贴子已经被作者于2006-5-13 9:02:17编辑过]


----------------解决方案--------------------------------------------------------
  相关解决方案