0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Personal outlook: don't cast the return of malloc, in C (don't use malloc in C++). In any project that isn't trivial, the probability of correctness is greater if one relies on the compiler.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
I just made one more try for the followin.

When you have the file as .c in MS compiler for the code
Code:
int main(){
int *ptr=malloc(10);
return 0;
}
but it gives when the file name is a .cpp file but with the .c file it does not run into any error for the code when executed. That is could not run into the hidden error.
0
Aztec's Avatar, Join Date: May 2006
Contributor
Try compiling in strict mode. You can even try online compiler .
0
Jamkirk's Avatar, Join Date: Dec 2006
Newbie Member
it could be alot simpler a problem...
try:
char *x = "C-PROGRAMMING";
char *Prog = (char *)malloc(strlen(14));
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
The online compiler gives error when not type casted.