Here is my code:
I am trying to assign the value "hello" to the pointer I created in main. In function sayHi, the string prints correctly after the pointer assignment. However, it doesn't print correctly in main. Please help.Code:#include <stdio.h> #include <string.h> void sayHi(char *); int main() { char *ptr; sayHi(ptr); printf("prt: %s\n", ptr); return 0; } void sayHi(char *str) { char *temp = "hello\0"; str = temp; printf("str: %s\n", str); }
Thanks