This is my code:
#include<stdio.h>
struct p{
char* d;
};
typedef struct p* pt;
int main(){
pt opt;
opt=(pt)malloc(sizeof(struct p));
scanf("%s",(opt->d));
printf("%s",opt->d);
getch();
return 0;
}
Everytime I run it , it accepts and prints the string fine but an error occur. On debugging it tells that there is a segmentation fault but doesn't points to where it is? What is going wrong , It's seems to be fairly correct.