我有这个结构
typedef struct tree_node_s{
char word[20];
struct tree_node_s *leftp,*rightp;
}fyllo
我想打印文件中的单词并使用 fprintf 问题出在 PROBLINE
void print_inorder(fyllo *riza,FILE *outp){
if (riza==NULL) return ;
print_inorder(riza->leftp,outp);
fprintf("%s",riza->word); //PROBLINE
print_inorder(riza->rightp,outp);
}
我正在编译,我遇到了这个问题
tree.c: In function ‘print_inorder’:
tree.c:35: warning: passing argument 1 of ‘fprintf’ from incompatible pointer type
这里有什么问题;
最佳答案
您错误地调用了 fprintf
。这个函数的声明是
int fprintf(FILE *restrict stream, const char *restrict format, ...);
因此,您应该将 FILE 指针作为第一个参数(您是否注意到您从未在函数中实际使用过 outp
?)。该行应写为
fprintf(outp, "%s", riza->word);
关于c - C语言打印字符串问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4135408/