Hello all prorgammers out there.
While just fiddling with the pointer concept of mine which is weak i wrote a very simple function to just give the addr of the array to the char type pointer so that i can refer the array using the pointer instead of the array name.
void pointTo(char* src, char* dst);
int main() {
char text[3] = {0}; // create a array with all elements 0
char* ptr = 0; // the char pointer which should refer the array
printf("\nThe addr in text is %p", text); // for debug
printf("\nThe addr in ptr is %p", ptr); // for debug
// here we pass the char pointer as first argument and the array
// pointer ie the addr pointed by array as second arg.
pointTo(ptr, text); // actual funtion call
printf("\nThe addr in text after function is %p", text);
printf("\nThe addr in ptr after function is %p", ptr);
ptr[0] = 'A'; // change using pointer instead of array name
ptr[1] = '\0';
printf("%s",text); // print the output
return 0;
}
// attempts to asssign the addr in destination to the addr in
// the source so that we can manipulate the array
void pointTo(char* src, char* dst) {
src = dst;
}
But this code jumps out as soon as i execute it.
My pointer concepts are a bit weak so can you point me to links which explain them in full depth and all that is required to tame them.