Top

Discussion

What is the Error of this program?

#include 
#include  
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

Answer: B

None

No comment is present. Be the first to comment.
Loading…

Post your comment