I am writing text to a file using the following program.
#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);
}
Let's say the input is:
Press Ctrl+D to stop \n\n
Enter text: this is a test
^Z
My question is the end of file character (ASCII value 26) will be written to the file or not ?
I verified using a hex editor in Windows ^Z
character is not written to the file.