Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102
Posted by Shahar Y on Apr 28th, 2008 | Filed under Unmanaged Code | 20 Comments

Recently, I ran into an interesting job interview question in C++ which I want to share. Lets take a look at the following code:

// Option A. 

char str1[] = "example";  

str1[1] = 'a';  

// Option B.  

char* str2 = "example";  

str2[1] = 'a';

What would happen if we compile and run this code ?


Continue Reading...
Write Article for Dev102

Write for Dev102!

We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution

Learn More