why is this not printing anything on the screen
Code:#include<stdio.h> #include<conio.h> int fun1 (int a[], int *b); main() { char name[15]={'j','o','h','n'}; char *ptr[3]; ptr[1]=name; printf("%c", *(ptr+2)); getch(); };
why is this not printing anything on the screen
Code:#include<stdio.h> #include<conio.h> int fun1 (int a[], int *b); main() { char name[15]={'j','o','h','n'}; char *ptr[3]; ptr[1]=name; printf("%c", *(ptr+2)); getch(); };
Only ptr[1] points to anything except garbage locations. On three runs of your program, it printed up a $, an 'l', and nothing.
Try this version of your program:
Code:#include<stdio.h> #include<conio.h> int fun1 (int a[], int *b); main() { char name[15]={'j','o','h','n'}; char *ptr[3]; ptr[1]=name; printf("\n ptr[1] now points to: %s\n", ptr[1]); printf("%c", ptr[1][2]); getch(); };
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"