Re: static *char myStringArray[] init problem?
Re: static *char myStringArray[] init problem?
- Subject: Re: static *char myStringArray[] init problem?
- From: lbland <email@hidden>
- Date: Tue, 20 Sep 2005 12:00:18 -0400
On Sep 20, 2005, at 10:26 AM, Chris Espinosa wrote:
static *char myStringArray[] = {"a", "b", "c", (char *)0};
You have declared an array of string pointers, and assigned one bytes'
worth of data to each 32-bit pointer.
Chris-
Thanks for your reply! I typed the question wrong. Sorry for my
ridiculous syntax error to begin with. I hope it doesn't confuse
things.
The actual statement is:
static char *myStringArray[] = {"a", "b", "c", (char *)0};
I misplaced the * in my original line. I think that is an array of
string pointers and that each element in that array is being assigned
to a constant string pointer?
I wrote a simple app shown below to verify that it works. For some
reason, simple apps work, but a much more complex app (loading the code
section from a framework) does not.
I also forced pointer alignment in the .o file using a seg1addr ld flag
and that seemed to fix the problem for now.
If you have any other ideas, or if I made a dumb mistake, please let me
know.
thanks!-
-lance
**************************
app:
**************************
static char *myStringArray[] = {"a1", "b2", "c3", (char *)0};
int main(int argc, const char *argv[])
{
printf("myStringArray[0]: %s\n", myStringArray[0]);
printf("myStringArray[1]: %s\n", myStringArray[1]);
printf("myStringArray[2]: %s\n", myStringArray[2]);
printf("myStringArray[3]: %s\n", myStringArray[3]);
}
**************************
result:
**************************
myStringArray[0]: a1
myStringArray[1]: b2
myStringArray[2]: c3
myStringArray[3]: (null)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden