#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char character='p';
fp=fopen("characters.txt", "wb+");
while(character!=' '){
printf("Enter the character (space to stop): ");
scanf("%c",&character);
fflush(stdin);
if(character!=' '){
fputc(character,fp);
}
}
rewind(fp);
printf("\nReading characters from the file: \n");
while((character=fgetc(fp))!=EOF){
printf("%c\n",character);
}
fclose(fp);
getch();
getch();
}
Comments
Leave a comment