Why do we have to initialize a pointer to a string when it is declared globally ?
I mean , This doesnt work
#include<stdio.h>
#include<conio.h>
char *str;
int main(void)
{
gets(str);
printf("%s",str);
}
But this works
char *str="1";
int main(void)
{
gets(str);
printf("%s",str);
}
Even upon initializing , it gives me weird outputs
When i entered 12345 as the input string , it printed only 345. Why ??