C - Data Types - Discussion

You Are Here :: Home > C > Data Types - Discussion

 



Q.

What will be output of following program?

#include
#include
int main(){
char *ptr1 = NULL;
char *ptr2 = 0;
strcpy(ptr1," g");
strcpy(ptr2,"shalini");
printf("\n%s %s",ptr1,ptr2);
return 0;
}

A. g shalini B. g (null)
C. (null) (null) D. Run time error

Answer: Option D
Explaination:

We cannot assign any string constant in null pointer by strcpy function.



Discussion

Your Comments Goes here...
NameDiscussion