Ask your own question, for FREE!
Computer Science 6 Online
OpenStudy (anonymous):

Point out the error in the following program.

OpenStudy (anonymous):

#include<stdio.h> #include<stdlib.h> int main() { char *ptr; *ptr = (char)malloc(30); strcpy(ptr, "RAM"); printf("%s", ptr); free(ptr); return 0; }

OpenStudy (anonymous):

Error: in *ptr = (char)malloc(30); Answer: ptr = (char*)malloc(30);

OpenStudy (anonymous):

Thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!