In the first program, the output is C++ ++ and i understood that s++ increments the address and the printf statement prints the string from the new base address.
#include<stdio.h>
void main()
{
char *s = "C++";
printf("%s ", s);
s++;
printf("%s", s);
}
now i have replaced the character pointer to a character array and tried to print the string before incrementing and after incrementing. I do not understand why my second program results in following compiler error "error: lvalue required as increment operand s++;". Thanks in advance.
#include<stdio.h>
void main()
{
char s[] = "C++";
printf("%s ",s);
s++;
printf("%s",s);
}