Re: [Q]What is different between strcpy and sprintf in this case
From: Barry Schwarz (schwarzb_at_deloz.net)
Date: 11/28/03
- Next message: Debashish Chakravarty: "Re: [OT] Indian C programmers and "u""
- Previous message: Sudheer Reddy Vakati: "Re: [OT] Indian C programmers and "u""
- In reply to: ios: "[Q]What is different between strcpy and sprintf in this case"
- Next in thread: Arthur J. O'Dwyer: "Re: [Q]What is different between strcpy and sprintf in this case"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Nov 2003 04:04:36 GMT
On 27 Nov 2003 19:18:11 -0800, ioswan@yahoo.com (ios) wrote:
>Hi
>
>Can someone tell me what is different between below case?
>
>strcpy(eventname, "MDCX_RSP");
>and
>sprintf(eventname, "MDCX_RSP");
>
Were you expecting any?
The contents of eventname (if an array) or the contents of the memory
it points to (if a pointer) will be the same for either statement in
this example. This would not be true if the second argument contained
anything sprintf would consider a conversion specification.
strcpy returns a pointer while sprintf returns an int but, since
either will be discarded, I don't think this is a relevant difference.
I would expect strcpy to be significantly faster but this is my
intuitive judgement and not part of the standard.
The only real difference I can see is that you need to include a
different header file depending on which you use.
<<Remove the del for email>>
- Next message: Debashish Chakravarty: "Re: [OT] Indian C programmers and "u""
- Previous message: Sudheer Reddy Vakati: "Re: [OT] Indian C programmers and "u""
- In reply to: ios: "[Q]What is different between strcpy and sprintf in this case"
- Next in thread: Arthur J. O'Dwyer: "Re: [Q]What is different between strcpy and sprintf in this case"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|