View Single Post
Old 02-07-07, 02:24 PM   #7
Imbroglio's Avatar
Join Date: Mar 2004
Posts: 1,271
Default Re: String Array in C

Originally Posted by Marvel_us
What if he just did the same thing without the

char myArray[10];
char str = "string!";

myArray[3] = str;

Wouldn't he get the same results or no?
first off, what you wrote is a syntax error

second, if he wrote

char myArray[10][X]; //where X is the max size of the string
char str[X] = "string!"; //haven't worked with strings in a while might have to call a function to convert the string to the char array. don't remember. (#include string.h)


myArray[3] = str;

then myArray[3] would contain the value of str, ie: "string!" and not a pointer to the pointer of the string.

HT: 360 -- Sony60A3000 -- Onkyo SR605 --> Polk cs2, monitor 60s and monitor 40s w/ Bic F12 sub -- PS3
XBL:Mr X3r0 -- PSN:Mr_X3r0

Rig- Asus P6X58D Premium - intel i7 920 @3.6 - EVGA GTX570 - Corsair HX1000 - Prolimatech Mega Shadow - WD640 - COOLER MASTER ATCS 840 - OCZ Gold 6GB DDR3 1600*

Imbroglio is offline   Reply With Quote