Miscellaneous › Others › c › C program correction
January 4, 2017 at 12:16 pm
#14321
Hari Prasaath K
Participant
Hi,
Line 8: Constant cannot be assigned to the pointer
In printf you have mentiond .32 it will throw an error
To get an output the above code can be rewritten as
#include <stdio.h>
void main()
{
char s[] = {'a','b','c',' ','c',' '};
char *p, *str, *str1;
p = &s[3];
str = p;
*str1 = 3;
printf("%dn", ++*p + ++*str1);
}
Output:
While Running using gcc compiler ans will 36.
*Note: Output will vary for different compilers.