Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- //#include<stdlib.h> --> When this include is not commented out, after build, you will get Warning C4013 'malloc' undefined; assuming extern returning int. In Win10 64bit, this will cause bad malloc behaviour and crash due to access violation.
- struct MyStruct{
- int a;
- };
- int main() {
- struct MyStruct *m = (struct MyStruct*)(malloc(sizeof(struct MyStruct)));
- m->a = 5; //will crash due to access violation at this line.
- printf("m->a = %d\nPress Enter...\n", m->a);
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement