首页 > 代码库 > C String

C String

What would happen if we compile and run this code ?

void main(){        // Option A.    char str1[] = "example";     str1[1] = a;     // Option B.     char* str2 = "example";     str2[1] = a;}
View Code

This code compiles but option B will produce a run time error.

http://www.dev102.com/2008/04/28/a-programming-job-interview-challenge/