#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
char *p1="Name";
const char *p2="Name";
char const *p3="Name";
char *const p4="Name";
const char *const p5="Name";
++p1;
++*p1;
++p2;
++*p2;
++p3;
++*p3;
++p4;
++*p4;
++p5;
++*p5;
}
While Compiling above code certain Compilation error came.
The errors are:
const.c: In function âmainâ:
const.c:17: error: increment of read-only location
const.c:19: error: increment of read-only location
const.c:20: error: increment of read-only variable âp4â
const.c:22: error: increment of read-only variable âp5â
const.c:23: error: increment of read-only location
Compilation error is expected but why in 19?
Is const char *pointer and char cons *pointer Same?
Please explain in detail Why the error is in Line 19?