Team Leader
26Dec2006,18:41   #11
DaWei's Avatar
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.
Go4Expert Founder
26Dec2006,19:52   #12
shabbir's Avatar
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.
Contributor
26Dec2006,20:09   #13
Aztec's Avatar
Try compiling in strict mode. You can even try online compiler .
Newbie Member
27Dec2006,07:46   #14
Jamkirk's Avatar
it could be alot simpler a problem...
try:
char *x = "C-PROGRAMMING";
char *Prog = (char *)malloc(strlen(14));
Go4Expert Founder
27Dec2006,09:55   #15
shabbir's Avatar
The online compiler gives error when not type casted.