Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

malloc() problem with 64 bit compilation

807578Mar 24 2010 — edited Apr 12 2010
Hi,

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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 10 2010
Added on Mar 24 2010
4 comments
718 views