int main()
int *a;
char *c;

is the statement *c=*a wrong??
showing seg fault!


  • Welcome to the forum, preetham1992! ;)

    When a program seg faults repeatedly, you can be sure that it has a serious error. ;)

    Pointers hold addresses, (not numbers like 20). Both pointer assignments are incorrect.

    Try this:
    int main()
       int *a,num=100;
       char *c,ch='z';
       printf("*a=%d, *c=%c \n",*a,*c);
       return 0;
    What does the int pointer a hold as it's value?
    The address of num. (not 100).

    What does the char pointer c hold as it's value?
    The address of ch. (not 'z').
  • thanks a lot!! actually it was an interview question!!:)
Sign In or Register to comment.