B
Bill Cunningham
I get a comparison error here and I see the problem but don't know how
to fix it. It's been so long. Here's the code.
#include <stdio.h>
int main(int argc, char **argv)
{
if (argc != 2) {
perror("argc error");
return -1;
}
int i, a;
i = a = 0;
FILE *fp;
if ((fp = fopen(argv[1], "r+")) == EOF) {
/* right here above argv[1] is a char ** and the first parameter of fopen is
char *. This is what I believe the problem is. How should I fix this?
*/
perror("fopen error");
return -1;
}
for (; i != EOF; ++i) {
fgetc(fp);
fputc(a, fp);
return 0;
}
fclose(fp);
}
to fix it. It's been so long. Here's the code.
#include <stdio.h>
int main(int argc, char **argv)
{
if (argc != 2) {
perror("argc error");
return -1;
}
int i, a;
i = a = 0;
FILE *fp;
if ((fp = fopen(argv[1], "r+")) == EOF) {
/* right here above argv[1] is a char ** and the first parameter of fopen is
char *. This is what I believe the problem is. How should I fix this?
*/
perror("fopen error");
return -1;
}
for (; i != EOF; ++i) {
fgetc(fp);
fputc(a, fp);
return 0;
}
fclose(fp);
}