S
sethukr
Hi everybody,
While i'm compiling the following program in GCC, it gives
"segmentation fault"
But GDB doesn't give any "segmentation fault"
What's the reason for this??
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main()
{
char name1[4];
int age1;
struct emp
{
char name[4];
int age;
};
struct emp *e1=malloc(sizeof(struct emp));
printf("enter name and age\n");
scanf("%s%d",name1,&age1);
printf("name1=%sage=%d\n",name1,age1);
e1->age=age1;
printf("\n%d",e1->age);
}
Thanks in advance,
Sethu
While i'm compiling the following program in GCC, it gives
"segmentation fault"
But GDB doesn't give any "segmentation fault"
What's the reason for this??
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main()
{
char name1[4];
int age1;
struct emp
{
char name[4];
int age;
};
struct emp *e1=malloc(sizeof(struct emp));
printf("enter name and age\n");
scanf("%s%d",name1,&age1);
printf("name1=%sage=%d\n",name1,age1);
e1->age=age1;
printf("\n%d",e1->age);
}
Thanks in advance,
Sethu