c - C语言打印字符串问题

标签 c string struct printf

我有这个结构

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/

相关文章:

c - 此处不允许函数定义

c - Mergesort 实现中的段错误

android - 由 : java. util.NoSuchElementException 引起

c++ - 结构中的枚举 - C 与 C++

c - 如何在 Makefile.am 或 configure.ac 中包含 -lm

编译 -ansi -pedantic -Wall 自动切换 gcc

strncpy 的 C++ 等价物

java - 如何重置这个随机字符串生成器? [Java]

c++ - 当输入到结构点中的双指针数组时程序崩溃

c++ - 我怎样才能防止无名的结构\union ?