Check the page about arrays.
Basically it's an array of 20 'char' type items. So yeah, if you try to put more than 20 characters in there, you'll be writing outside of the memory assigned to it, most likely causing a crash.
Bak - Sun Jun 08, 2008 2:13 pm
Post subject:
array is basically a bunch of variables... if you wanted to have a word you could do:
char letter0 = 'a';
char letter1 = 'p';
char letter2 = 'p';
char letter3 = 'l';
char letter4 = 'e';
char letter5 = 0; // 0 or '\0' means its the end
|
or
char letters[6] = "apple";
|
and then you can extract letters with letters[0], letters[1], ect.
it's also nicer because you can loop over the entire array with a variable... so say you wanted to clear the letters (set them all to 0), you'd have to do
letter0 = 0;
letter1 = 0;
letter2 = 0;
letter3 = 0;
letter4 = 0;
letter5 = 0;
|
or with arrays you could do it a in a loop
for (int i = 0; i < 6; ++i)
letters[i] = 0;
|
For floating point ranges, you can read the wikipedia link brain posted... there's a chart about half way down that lists the "Largest normalized number". Basically for 32 bit floating point numbers it's about 2^128 which is the 3.4 * 10^38 and for 64 bit floating point numbers it's about 2^1024 which is the 1.7 * 10^308 from your site.
cplusplus.com is wrong, however, in that the range "1.7e +/- 308" means 1.7 * 10^(+/- 308) when what they really mean is +/- 1.7 * 10^308 (otherwise floating point numbers couldn't represent negative numbers, or even zero!)
my first introductory c++ book made the same mistake, someone should send them an e-mail
k0zy - Sun Jun 08, 2008 4:01 pm
Post subject:
To zero an array you should use memset.
http://www.cplusplus.com/reference/clibrary/cstring/memset.html
char string[6];
memset(string, 0, 6); |
Bak - Sun Jun 08, 2008 8:48 pm
Post subject:
but then he's just memorizing functions