0

So here is my attempt at it but I'm getting a few errors which I don't know how to fix. 17.2 Warning : passing argument 2 of putc makes pointer from integer without a cast. C:\mingw ....... note expected Struct FILE* but' but argument is of type int.

  #include <stdio.h>
  #include <stdlib.h>

  int main (void) {
FILE *fp;
int c;
char copywords;

fp = fopen("gues20.txt", "r");
if (fp == NULL)
exit(1);

c = getc(fp);
while(c != EOF)
{
putc(c, copywords);
c = getc(fp);
}
printf("%d", copywords);
}
4

2 回答 2

0

putc的第二个参数是文件流。但是你通过了一个简单的字符。利用:

while(c != EOF)
{
putc(c, stdout);
c = getc(fp);
}

在标准输出中打印。

于 2012-12-17T15:08:14.293 回答
0

这个:

putc(c, copywords);

是错的。首先,copywords从不在此行之上初始化或使用,因此引用它显然是错误的。二、原型putc()为:

int putc(int c, FILE *stream);

这解释了您的编译器警告。

于 2012-12-17T15:08:45.150 回答