edited by
533 views
0 votes
0 votes

Find the out put of the following C program.    

main()
{
    char *ptr = "techtud";
    char p= (*ptr)++;
    printf("%s\n",ptr);
}

the output of the program came as$?$

edited by

1 Answer

1 votes
1 votes
first of all char *p = "techtud"  is wrong
char *p means , p can hold only address not a string
to assign it a string u need to assign memory dynamically at runtime or make it as char p[] instead of char* p

if we ignore error and talk about logic then (*ptr)++  this line does this
(*ptr)  means value at address that ptr hold and ptr holds base address of array having techtud
so *ptr == t
now (t)++  which is (ascii value of t)++  which is equals to u   since it is post increment changes will take place in actual variable to which ptr is pointing
and p will will assigned t coz of post increment

Related questions

1 votes
1 votes
1 answer
1
1 votes
1 votes
2 answers
3