0

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_inorder(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;

1
  • Don't ignore compiler warning. Include appropriate header file. Commented Nov 10, 2010 at 1:54

3 Answers 3

6

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);
Sign up to request clarification or add additional context in comments.

1 Comment

or, as they say RTFM... especially when you've never used the function before :)
3

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

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

Comments

2

Try changing

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

to

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.