C String

What would happen if we compile and run this code ?app

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.ide

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

相關文章
相關標籤/搜索