B
Bill Cunningham
I wrote this little reader program I like. It's just for fun anyway but
what does it mean that getc can be implemented as a macro and be reused
while fgetc can't? The only difference I see in them is the f in front. Also
Where I used != in my code I tried using the ! and I was given an error.
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int a;
FILE *fp;
if ((fp = fopen(argv[1], "r")) == NULL) {
fputs("fopen error\n", stderr);
exit(1);
}
while ((a = getc(fp)) != EOF)
putc(a, stdout);
return 0;
}
while((a = getc(fp)) !EOF)
I wrote the above and something was wrong.
Bill
what does it mean that getc can be implemented as a macro and be reused
while fgetc can't? The only difference I see in them is the f in front. Also
Where I used != in my code I tried using the ! and I was given an error.
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int a;
FILE *fp;
if ((fp = fopen(argv[1], "r")) == NULL) {
fputs("fopen error\n", stderr);
exit(1);
}
while ((a = getc(fp)) != EOF)
putc(a, stdout);
return 0;
}
while((a = getc(fp)) !EOF)
I wrote the above and something was wrong.
Bill