I was just wondering about character array offsets and
array names. If I declare:
char* a;
char* theString[]="Hello World";
a=theString;
a++;
Will a[0] now show 'e'?
I was just wondering about character array offsets and
array names. If I declare:
char* a;
char* theString[]="Hello World";
a=theString;
a++;
Will a[0] now show 'e'?
A minor correction:
The variable a is not an array so you really shouldn't be using the [] array indexing scheme. After the above code is run, a will point to the second element of theString which means that *a will equal 'e'.Code:char* a; char theString[]="Hello World"; // Notice no '*' after char a=theString; a++;
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
Look at my program, in my case, it print's 'e':
Code:#include <stdio.h> int main(void) { char *ptrStr; char *str = "Hello World"; ptrStr = str; printf("%c\n",*(++ptrStr)); getchar(); return 0; }
Thanks. This means array names are much more powerful than I thought!