codexmax
10-22-2009, 07:30 AM
I have been looking at this for so long and can't figure out whats wring with it. Any help would be much appreciated!! Assume all the necessary header files are included.
char *s2 = "Peter Piper";
char *s4[]= { "c++", "is", "peachy" };
//I'm a bit confused at this point if this will compile and if so what is the //output. If not, what is the problem.
strcpy(s2, s4[1]); // it will copy "is" into s2 and it will work and compile,
cout << s2 << endl; //output is "is" But this is read only data... so not sure
for(int i =0; i < 3; i++) // i'm not sure what this would do...
cout << s4[i] [0] << endl;
char *s2 = "Peter Piper";
char *s4[]= { "c++", "is", "peachy" };
//I'm a bit confused at this point if this will compile and if so what is the //output. If not, what is the problem.
strcpy(s2, s4[1]); // it will copy "is" into s2 and it will work and compile,
cout << s2 << endl; //output is "is" But this is read only data... so not sure
for(int i =0; i < 3; i++) // i'm not sure what this would do...
cout << s4[i] [0] << endl;