I need to modify the below program by changing from:
fscaf() to getc()
and
fprintf() to putc()
.... i am unfamiliar with getc/putc, and have tried messing with changing out a few things, only to find errors during compile.
heres my code..
thanks in advance:
Code:
#include <stdio.h>
int main()
{
FILE *afile, *anotherfile;
int number;
afile=fopen("fun-with-numbers.txt","r");
anotherfile=fopen("more-fun-with-numbers.txt","w");
if (afile==NULL)
{
printf("Could not open file for reading.\n");
}
else
{
fprintf(stdout,"Success opening file.\n\n");
fscanf(afile,"%d", &number);
while (feof(afile)==0)
{
printf("%d\n", number);
fprintf(anotherfile,"%d\n", number);
fscanf(afile,"%d", &number);
}
/* do not pass a NULL pointer to fclose() */
fclose(afile);
}
return 0;
}
Also, my instuctions ask me to "Use fun-with-chars.txt as the input file and more-fun-with-chars.txt as the output file."
here is the given fun-with-chars.txt input file:
Code:
100 99 98 97 96 95 94 93 92 91 90