Quote:
struct emp e[2];
Here you are declaring an array having
two items, namely
e[0]
and
e[1]
.
While here
Quote:
for(i=0;i<=2;i++){/*...*/}
and here
Quote:
for(j=0;j<=2;j++){/*..*/}
You are assuming the array has
three items, namely
e[0]
,
e[1]
and
the not existing e[2]
.
I see a problem...
[update]
Quote:
scanf("%s",&e[i].ename);
This is another mistake: you never allocated memory for the
ename
string.
You either define it as an array of characters, e.g
struct emp
{
int eid;
int sid;
char ename[64];
};
(assuming 64 is a resonable maximum size for your strings)
or use the malloc function to allocate dynamic memory (that you have to release at the end), e.g.
printf("enter name of employee %d\t",i+1);
e[i].ename = (char *) malloc(64 * sizoef(char));
if (! e[i].ename)
{
}
scanf("%s",&e[i].ename);
[/update]