malloc() problem with 64 bit compilation
807578Mar 24 2010 — edited Apr 12 2010Hi,
I've been trying to execute the following piece of code in 64 bit compilation.
It crashes after malloc(). The same works fine in 32 bit compilation.
#include<stdio.h>
int main()
{
struct student{
int number;
};
struct student st1;
int number;
printf("enter number: ");
scanf("%d",&number);
st1 = (struct student )malloc(sizeof(struct student));
st1->number = number;
printf("Number: %d\n",st1->number);
return 0;
}
trying to initialize dynamically allocated memory leads to crash.
Can somebody help me out!