Hello folks,
the following program will simply read whats inside test.txt and will display that on the screen. However, it will also print the ascii value for the empty line that follows the text. Could you please tell me what i should be doing in order to have the text as the only output on the screen (after all, is this a good way of displaying my file anyways?)
Also, what if i am working with binary files. how can i display the contents of such files?
thanks,
#include <stdio.h>
main(){
FILE *ptr;
char ch;
ptr = fopen("test.txt","r+");
if (ptr==NULL)
printf("Error: File does not exist\n\n");
else
do
putchar(ch=getc(ptr));
while(ch != EOF);
close(ptr);
}