Hello again,
Ran into a problem with the following, maybe someone can explain.
char* str="abc";
*(str+0) = *(str+2); //Program Dumps
or
char temp[]="abc";
char* str = temp;
*(str+0) = *(str+2); // no problem
Above values mean nothing but I dont understand why the first one does'nt act the same as the second. Our book says either of these are valid declarations:
char str[SIZE]="abc";
or
char* str="abc";
The original problem was to output the reverse a string using pointers without having [ or ] anywhere in your program. The assignment is done as my instructor informed me that I did'nt have to "reconstruct" the string, but any help understanding the above would be greatly appreciated.
BH



LinkBack URL
About LinkBacks


