所以这里是我的尝试,但我收到了一些我不知道如何解决的错误。 17.2警告:传递putc的参数2会使得整型指针没有转换。 C:\ mingw .......注意期望结构FILE *但'但参数是int类型。如何将文件中的字符放入char字符串中?
#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);
}
http://www.cplusplus.com/reference/cstdio/putc/ – 2012-12-17 15:07:57
如果你真的想把字符放在一个字符串中,那么'fputc()'就没有问题了。标题是否错误? – unwind