lets take a look at the following code:-
#include<stdio. h>
#include<conio. h>
struct tag{
int age;
char *name;
}a;
void main()
{
clrscr();
puts("enter name ");
scanf("%s",a.na me);
fflush(stdin);
puts("enter");
scanf("%d",&a.a ge);
printf("%s\t%d" ,a.name,a.age);
getch();
}
its look ok to me, but as i run this, i face some problem, i m not able
to assign value to name
but as i declare a structure's instance i.e, "a" within the main
program, i m able to assign a value in a.name.
why this is so,
plz help me i m very confused
#include<stdio. h>
#include<conio. h>
struct tag{
int age;
char *name;
}a;
void main()
{
clrscr();
puts("enter name ");
scanf("%s",a.na me);
fflush(stdin);
puts("enter");
scanf("%d",&a.a ge);
printf("%s\t%d" ,a.name,a.age);
getch();
}
its look ok to me, but as i run this, i face some problem, i m not able
to assign value to name
but as i declare a structure's instance i.e, "a" within the main
program, i m able to assign a value in a.name.
why this is so,
plz help me i m very confused
Comment