Which lines contain errors (compilation errors, runtime errors, undefined behavior etc.), if any?

    char a[] = "123";  //1
    char b[5] = "123";  //2
    const char *c = "123";  //3
    a[3] = '3';  //4
    b[4] = '3';  //5
    c[2] = '5';  //6
Explanation
Pointer c points out to the constant memory area that stores the line literal "123". Therefore, a compilation error will occur in line 6 while trying to write to the constant memory area.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback