473,503 Members | 9,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

diff between sprintf() and fprintf()

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

May 16 '06 #1
9 1733
"mknarang.nsit" <mk***********@gmail.com> writes:
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).
--
"If I've told you once, I've told you LLONG_MAX times not to
exaggerate."
--Jack Klein
May 16 '06 #2
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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
May 16 '06 #3
mknarang.nsit wrote:
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

May 16 '06 #4

"Robert Gamble" <rg*******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
mknarang.nsit wrote:
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".


And in the English language, we capitalize proper nouns like "English",
unless you mean to imply spin on a ball...
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


--
Fred
May 16 '06 #5

"Fred Kleinschmidt" <fr******************@boeing.com> wrote in message
news:Iz********@news.boeing.com...

"Robert Gamble" <rg*******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
mknarang.nsit wrote:
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.
Actually, two spaces are required after a period. One is insufficient.
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...
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


--
Fred


The Grue
May 17 '06 #6

"The Grue - James T. Sprinkle" <th******@hotmail.com> wrote in message
news:dM*****************@news01.roc.ny...

"Fred Kleinschmidt" <fr******************@boeing.com> wrote in message
news:Iz********@news.boeing.com...

"Robert Gamble" <rg*******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
mknarang.nsit wrote:
> 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.
Actually, two spaces are required after a period. One is insufficient.
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...
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


--
Fred


The Grue


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

barry
May 17 '06 #7
Barry wrote:

"The Grue - James T. Sprinkle" <th******@hotmail.com> wrote in message
news:dM*****************@news01.roc.ny...

"Fred Kleinschmidt" <fr******************@boeing.com> wrote in message
news:Iz********@news.boeing.com...

"Robert Gamble" <rg*******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
> mknarang.nsit wrote:
>> 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.
Actually, two spaces are required after a period. One is insufficient.
> 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...

> 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
>

--
Fred


The Grue


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:

Barry wrote: "The Grue - James T. Sprinkle" <th******@hotmail.com> wrote in message
"Fred Kleinschmidt" <fr******************@boeing.com> wrote in message
"Robert Gamble" <rg*******@gmail.com> wrote in message

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.
Actually, two spaces are required after a period. One is
insufficient.

.... 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/>
May 17 '06 #8
On 2006-05-17, The Grue - James T. Sprinkle <th******@hotmail.com> wrote:

Actually, two spaces are required after a period. One is
insufficient.


The typographical (not grammatical) need for that faded with the
typewriter.
May 17 '06 #9
"The Grue - James T. Sprinkle" <th******@hotmail.com> wrote:
"Robert Gamble" <rg*******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
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.


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
May 22 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5110
by: CJ | last post by:
Ok, I've got a string class that stores the data in a dynamically allocated "char* m_pData" variable. I'd like to write a member function similiar to "sprintf" for this class. When implementing...
10
9920
by: ios | last post by:
Hi Can someone tell me what is different between below case? strcpy(eventname, "MDCX_RSP"); and sprintf(eventname, "MDCX_RSP"); Thanks, Leon
3
42095
by: huey_jiang | last post by:
Hi All, I am trying to figure out a right syntax to convert an integer array into hex array. sprintf worked for me on doing single integer: int i, Iarray, n=15; char buf; sprintf(buf,...
9
1919
by: Matt Garman | last post by:
I'm trying to develop (for my own personal use) a general "messaging facility" in C. The idea is that the facility will be used for both debugging/logging and user interfacing. I'd like it to be...
1
3504
by: jimjim | last post by:
Hello, I was wondering about the implications of giving as an argument to sprintf a different data type from the one specified in the format argument. This type of question along with some...
9
6501
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
4
4933
by: Andreas Kasparek | last post by:
Hola! I'm preparing my master thesis about a XML Merge Tool implementation and was wondering if there is any open standard for XML diff regarding topics like: - is a diff result computed on...
66
3052
by: gyan | last post by:
Hi All, I am using sprintf and getting starnge output in following case char temp_rn; memset(temp_rn,'\0',12); sprintf(temp_rn,"0%s",temp_rn); the final value in temp_rn is 00 how it...
173
13762
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.