here is some problem in structures
- From: "ashu" <riskyashish@xxxxxxxxx>
- Date: 7 Feb 2006 07:30:02 -0800
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.name);
fflush(stdin);
puts("enter");
scanf("%d",&a.age);
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
.
- Follow-Ups:
- Re: here is some problem in structures
- From: Hemant Mohan
- Re: here is some problem in structures
- From: Hemant Mohan
- Re: here is some problem in structures
- From: Vladimir S. Oka
- Re: here is some problem in structures
- From: Mike Wahler
- Re: here is some problem in structures
- From: Chris Dollin
- Re: here is some problem in structures
- Prev by Date: Re: is there a symbolic constant telling us we are using a C89 compiler?
- Next by Date: Re: segmentation fault
- Previous by thread: whats there in C that is not in C++ and VC++
- Next by thread: Re: here is some problem in structures
- Index(es):
Relevant Pages
|