diff between sprintf() and fprintf()

M

mknarang.nsit

i have just started studying C.I know C++ before this.i havent reallly
understand the concept of sprintf().could any one plz tell me what is
the difference b/w sprintf() and fprintf() through an example
 
B

Ben Pfaff

mknarang.nsit said:
i have just started studying C.I know C++ before this.i havent reallly
understand the concept of sprintf().could any one plz tell me what is
the difference b/w sprintf() and fprintf() through an example

sprintf() puts its output in a string.
fprintf() writes its output to a stream (a file or device).
 
R

Richard Heathfield

mknarang.nsit said:
i have just started studying C.I know C++ before this.i havent reallly
understand the concept of sprintf().could any one plz tell me what is
the difference b/w sprintf() and fprintf() through an example

In your C book, look at the type of the first parameter to sprintf, and the
type of the first parameter to fprintf. In each case, the parameter
determines the place where the output of the function will be written. That
they are of different types for the two functions, then, is significant.
 
R

Robert Gamble

mknarang.nsit said:
i have just started studying C.I know C++ before this.i havent reallly
understand the concept of sprintf().could any one plz tell me what is
the difference b/w sprintf() and fprintf() through an example

1) Sentences start with capital letters, like this one.
2) Space comes after a period and before the beginning of the next
sentence, one or two is fine.
3) In the english language we always capitalize the word "I".
4) Don't use abbreviations like "plz" in a technical group like this
one if you want to be taken seriously.

Also, since you are posting from Google Groups, please be sure to read
<http://cfaj.freeshell.org/google/> before posting a followup.

Now to your question: sprintf writes to a character buffer, fprintf
writes to a stream. See your local documentation or a good C book for
the details.

Robert Gamble
 
F

Fred Kleinschmidt

Robert Gamble said:
1) Sentences start with capital letters, like this one.
2) Space comes after a period and before the beginning of the next
sentence, one or two is fine.
3) In the english language we always capitalize the word "I".

And in the English language, we capitalize proper nouns like "English",
unless you mean to imply spin on a ball...
 
T

The Grue - James T. Sprinkle

Actually, two spaces are required after a period. One is insufficient.
And in the English language, we capitalize proper nouns like "English",
unless you mean to imply spin on a ball...

The Grue
 
B

Barry

The Grue - James T. Sprinkle said:
Actually, two spaces are required after a period. One is insufficient.


The Grue

Two is what you learned in typing, one is usually sufficient and zero is ok
if
you parser works well.

barry
 
C

CBFalconer

Barry said:
Two is what you learned in typing, one is usually sufficient and zero is ok
if
you parser works well.

I have left this monstrosity as it appears on my system. Your
comment is nearly meaningless. It is almost as bad to fail to snip
irelevant material as to fail to quote. Below is the way it SHOULD
have looked, IMO:
.... snip ...

Two is what you learned in typing, one is usually sufficient and
zero is ok if you parser works well.

I hope you see the difference. Just some judicious deletia,
followed by minor reformatting. This tends to encourage others to
read it, which I presume is your (and my) objective.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
R

Richard Bos

The Grue - James T. Sprinkle said:
Actually, two spaces are required after a period. One is insufficient.

This has never been true outside the USA, and ever there, it was only
"necessary" (the real need is not apparent from a normal layout POV) on
typewriters. Proper typography is, and always has been, a single space.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top