array of char

Feb 27, 2011 at 12:50pm
ok this is something weird. a character variable can only store 1 character but an array of char having only 1 element can store huge values like "weeeerfffffffssssssssssssssssssssssssssaaaaaaaaaaaaaaaaadhvgj"
HOW IS THIS POSSIBLE?????
Feb 27, 2011 at 1:28pm
It's not.
char array[1]="stringLongerThatOneCharacter";
will throw an error.
Feb 27, 2011 at 1:40pm
i didn't use assignment operator. i inputted a value using cin. try it
Feb 27, 2011 at 1:53pm
Inputing from cin seems to exceed the array limit and gets into unassigned memory space. Try that in a structure and you'll see that everything messes up.
Feb 27, 2011 at 2:02pm
true
Feb 27, 2011 at 2:02pm
true
Topic archived. No new replies allowed.