i am writing a program.. in that i am needed to represent an array using pointers only..(its a constraint i ve to work with).. the prob i am facing can be shown by this small program.. pls help me rectify with
#include <stdio.h>
#include <conio.h>
void main()
{
char a[4],*b;
a[0]=2;
a[1]=2;
b[0]=a[0];
printf("%s",a);
getch();
}
i have trouble whenever i try to assign b a value.. like here b[0]=a[0] gives the exception.. even if i have b[0]=0 it will give an exception
the program is giving an nullreferenceexception.. saying that i cannot dereference a null object.. how do i fix this.. or are there any alternate ways to handle this..