When I try to read input from a file named "file1", my program correctly displays the number of characters in the file, but in an unrecognized character format. Below is the code
#include <stdio.h>
#include <stdlib.h>
void db_sp(FILE*);
int main(int argc,char *argv[])
{
FILE *ifp,*ofp;
if(argc!=2) {
fprintf(stderr,"Program execution form: %s infile\n",argv[0]);
exit(1);
}
ifp=fopen(argv[1],"r");
if (ifp==NULL) printf("sdaf");
//ofp=fopen(argv[2],"w+") ;
db_sp(ifp);
fclose(ifp);
//fclose(ofp);
return 0;
}
void db_sp(FILE *ifp)
{
char c;
while(c=getc(ifp) !=EOF) {
//printf("%c",c);
putc(c,stdout);
if(c=='\n' || c=='\t' || c==' ')
printf("%c",c);
}
}