开发者

print string problem in C

开发者 https://www.devze.com 2023-01-24 18:40 出处:网络
i have this struct typedef struct tree_node_s{ char word[20]; struct tree_node_s *leftp,*rightp; }fyllo i want to print the word in a file and im using fprintf

i have this struct

typedef struct tree_node_s{
    char word[20];

    struct tree_node_s *leftp,*rightp;

    }fyllo

i want to print the word in a file and im using fprintf the problem is in PROBLINE

void print_inorder(fyllo *riza,FILE *outp){

     if (riza==NULL) return ;
     print_in开发者_StackOverflow社区order(riza->leftp,outp);
     fprintf("%s",riza->word);  //PROBLINE
     print_inorder(riza->rightp,outp);
                }

im compiling and i got this problem

tree.c: In function ‘print_inorder’:
tree.c:35: warning: passing argument 1 of ‘fprintf’ from incompatible pointer type

whats the problem here;


You are calling fprintf wrongly. The declaration of this function is

 int fprintf(FILE *restrict stream, const char *restrict format, ...);

Therefore, you should put the FILE pointer as the first argument (did you notice that you have never actually used outp in the function?). The line should be written as

fprintf(outp, "%s", riza->word);


The first argument to fprintf should be the FILE* to print to:

fprintf(outp, "%s", riza->word);


Try changing

fprintf("%s",riza->word); 

to

fprintf(outp, "%s", riza->word);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号