questions about sprintf, sscanf, printf, scanf, fscanf, fprintf! 
Author Message
 questions about sprintf, sscanf, printf, scanf, fscanf, fprintf!

Hello everybody!
Sometimes, read some words in this newsgroup,
someone said that use sprintf or sscanf instead of printf or scanf!
why?
and, I recently find Paul, use a statment:
fprintf("Text here",stdout);
i know it is also posible to use this statment to display some text on the
std output! but is it use this statment rather than just use printf("Text
here");
???


Mon, 29 Oct 2001 03:00:00 GMT  
 questions about sprintf, sscanf, printf, scanf, fscanf, fprintf!
I don't all off you question but I give it a try.

Quote:

> Hello everybody!
> Sometimes, read some words in this newsgroup,
> someone said that use sprintf or sscanf instead of printf or scanf!
> why?

sprintf? Are you sure I think you are talking of fgets instead of gets.
sprintf does not give you any output because it just write the formatted
string to it's first argument

man sprintf will tell you that.

You are well advised to use sscanf for cheking input which was read in
with fgets. The reason for that can be found in the C-FAQ (just look for
scanf and why it is unwise to use)

Quote:
> and, I recently find Paul, use a statment:
> fprintf("Text here",stdout);

Maybe Paul want to show the usage off fprintf and fprintf is a to use to
write to stderr. printf write just to standard output, but if s.th goes
wrong you normally did not want to clutter normal output and error
output together. I think it's a matter of taste. If that isn't the case
s.o else will surely correct me.

Regards
Friedrich



Mon, 29 Oct 2001 03:00:00 GMT  
 questions about sprintf, sscanf, printf, scanf, fscanf, fprintf!

Quote:

>I don't all off you question but I give it a try.


>> Hello everybody!
>> Sometimes, read some words in this newsgroup,
>> someone said that use sprintf or sscanf instead of printf or scanf!
>> why?

>sprintf? Are you sure I think you are talking of fgets instead of gets.
>sprintf does not give you any output because it just write the formatted
>string to it's first argument

>man sprintf will tell you that.

>You are well advised to use sscanf for cheking input which was read in
>with fgets. The reason for that can be found in the C-FAQ (just look for
>scanf and why it is unwise to use)
>> and, I recently find Paul, use a statment:
>> fprintf("Text here",stdout);

CORRECTION:

fprintf(stdout,"Text here");

:)

(It'll work.)

Quote:
>Maybe Paul want to show the usage off fprintf and fprintf is a to use to
>write to stderr. printf write just to standard output, but if s.th goes
>wrong you normally did not want to clutter normal output and error
>output together. I think it's a matter of taste. If that isn't the case
>s.o else will surely correct me.

There. You asked for a correction and I was glad to help!!  :)  :)  :)

Now...this is an EXAMPLE of what you were saying earlier because
you were RIGHT:

fprintf(stderr, "This is an error message.  Ha ha.\n\n");

- Show quoted text -

Quote:
>Regards
>Friedrich



Mon, 29 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. anything to replace the scanf/fscanf/sscanf?

2. Question about Fprintf, fscanf for floats

3. printf / sprintf question

4. printf / sprintf question

5. Simple scanf/printf question

6. tiny question on format of scanf and printf

7. Beginner question - printf and scanf

8. How to wrap fprintf / sprintf

9. fprintf and sprintf

10. Fprintf/Fscanf

11. fprintf() & fscanf()

12. I can not do simple fscanf and fprintf

 

 
Powered by phpBB® Forum Software