Re: sscanf problem
Re: sscanf problem
- Subject: Re: sscanf problem
- From: lbland <email@hidden>
- Date: Fri, 30 Jan 2004 15:15:45 -0500
On Jan 30, 2004, at 2:51 PM, Chris Reed wrote:
I realize this is a little old, but I wanted to make sure no one was
left with the wrong impression.
Yes, I followed up in a later email saying that I read sscanf() as
sprintf() so the whole thing was an embarrassing wash. Thanks for
bringing it up again ... ;-)
You were thinking of something like this:
const char* const s = "a constant string";
No, I was thinking about something like this:
char *s = "abcdef";
strcpy(s, "1234");
here is a paragraph from a book I have that explains it:
"Traditionally - at least under UNIX - string constants are placed in
read/write storage and no two string constants are ever represented by
the same block of storage, even when they contain the same characters.
We consider it a bad programming style to modify the contents of a
string constant or to depend on distinct copies in storage, and Draft
Proposed ANSI C agrees by allowing strings to share storage and to be
in read-only memory. However, it is known that some UNIX library
routines do modify their string arguments, which are often string
constants. When a pointer to a writable string must be used, it is
better to initialize an array of characters than to establish a pointer
to a string constant."
that is what I was referring to, but it had nothing to do with the
original email post.
thanks!-
-lance
Lance Bland
mailto:email@hidden
VVI
888-VVI-PLOT
http://www.vvi.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.