Article:
 |
|
Strings in Cocoa: Part I
|
| Subject: |
|
Comparing strings |
| Date: |
|
2001-07-03 14:38:00 |
| From: |
|
wcray
|
Response to: Comparing strings
|
> Actually, comparing string1 and string2
> with == didn't work
> when I compiled Mike's code fragment as
> a standard tool.
> This is surprising because...
Actually not unexpected. string1 and string2
were declared as unbounded char arrays, which
gcc assumes aren't constant strings (while
type char *s with initializers are assumed
to be constant).
I believe the logic is that
char foo[] = "yabba dabba";
declares foo to be a character array, and
then the initializer puts data into it, while
char *foo2 = "yabba dabba";
declares foo2 to be a pointer, and the
initializer points it to a string containing
"yabba dabba" that already exists in
the memory space.
|
Showing messages 1 through 4 of 4.
-
Comparing strings
2001-07-03 16:44:43
canyonrat
[View]
-
Comparing strings
2001-07-04 18:36:41
bigboytoddy
[View]
-
Comparing strings
2001-07-04 23:33:56
canyonrat
[View]
>were declared as unbounded char arrays, which
>gcc assumes aren't constant strings (while
>type char *s with initializers are assumed
>to be constant).
That's really good to know. Thanks!