Select lines which contain errors

void f(char* p) {
    char s[] = "ABCD";            //1
    const char* pc = s;           //2
    pc[3] = 'd';                  //3
    pc = p;                       //4 

    char* const cp = s;           //5
    cp[3] = 'f';                  //6
    cp = p;                       //7

    const char* const cpc = s;    //8
    cpc[3] = 'a';                 //9
    cpc = p;                      //10
}
Explanation
3 - You can not change a constant, pc - is a pointer to the constant;
7 - You can not change a constant pointer, cp - is const pointer;
9 - You can not change a constant, cpc - is a constant pointer to a constant;
10 - You can not change a constant pointer, cpc - is a constant pointer to a constant;

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты