Character Array MCQ 1 : String Assigned to Character Pointer in C Programming Language



String / Character Array MCQ 1 : String Assigned to Character Pointer
Predict the Output of the Following Program ?

#include<stdio.h>
void main()
{
char *str="Pritesh";
printf("%s",str);
}

Options :

[arrowlist]

  • Error : Declaration not Allowed
  • Pritesh
  • Illegal Pointer Initialization
  • None Of these

[/arrowlist]
[toggle title=”Output”]Pritesh[/toggle]


How and Why ?

  1. String Can be Initialized to Character Pointer
  2. Here Base Address of the String is Stored in Pointer Field
  3. For More Details : Click Here [String Initialization Techniques ]