Which lines will be executed/compiled with errors?
char *s1((char *)("foo"));  //1
char s2[] = "foo";  //2
char *s3 = (char *) new char[10];  //3
s1[2] = 'a';  //4
*s2 = 'b';  //5
3[s3] = 'c';  //6
Explanation
The fourth line tries to change the constant memory area. The sixth line is correct. You can read the details here: Accessing array elements.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes