What is the output of following code:
#include <stdio.h>
main()
{
char *p = 0;
*p = 'a';
printf("value in pointer p is %c\n", *p);
}
Answers
Answer:
i think many of the compilers will give an error or may your program will be crash bcz first of all you must initilize a pointer variable ,which points a valid memory location.
******here,char *p=0(i.e,p is a null pointer)null pointer means a pointer variable doesn’t contain of any valid memory location of memory block.
your prog may crash or error
if:-1)assigning value to uninitilized pointer{int *P,m=100;*p=m;}
2)assigning value to a pointer variable{int
Answer:
here,char *p=0(i.e,p is a null pointer)null pointer means a pointer variable doesn’t contain of any valid memory location of memory block.
your prog may crash or error
if:-1)assigning value to uninitilized pointer{int *P,m=100;*p=m;}
2)assigning value to a pointer variable{int *p,m=100;p=m;}…….