3
我正在使用以下程序将文本写入文件。^Z字符是否写入文件?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int ch;
FILE *fp;
fp = fopen("myfile.txt", "w");
if(fp == NULL)
{
printf("Error opening file\n");
exit(1);
}
printf("Press Ctrl+D to stop \n\n");
printf("Enter text: ");
while((ch=getchar()) != EOF)
{
fputc(ch, fp);
}
fclose(fp);
}
假设输入为:
Press Ctrl+D to stop \n\n
Enter text: this is a test
^Z
我的问题是文件字符(ASCII值26)年底将被写入文件或没有?
您的问题似乎呈现Windows。即使如此,但DOS。应该调整你的标签。 –
你是如何得出结论:'^ Z'是26代表的ASCII字符? –
@RSahu它实际上是Ctrl + Z – Cody