C - runtime error, `malloc(sizeof(int))` causing program to crash
Here is a piece of code:
int* linenump;
// ... other stuff
printf("----\n");
linenump = malloc(sizeof(int));
printf("*****\n");
The program only print out ---- then stopped, pop up a window says that
the program has stopped, I paste the code in VS then build&run it, no
errors, the program works fine.
It's a console application.
So, what I want to know is, in what situation that this will happen? and
how should solve it?
Thanks in advance.
No comments:
Post a Comment