adplus-dvertising
frame-decoration

Question

What is the Error of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()

{
     char *ptr;
     *ptr = (char)malloc(30);
     strcpy(ptr, "RAM");
     printf("%s", ptr);
     free(ptr);
     return 0;
}

a.

Error: in strcpy() statement.

b.

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

c.

Error: in free(ptr);

d.

No error

Posted under C Programming

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

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the Error of this program?