could sombody tell me what the field length of integer and string are please.
thanks
could sombody tell me what the field length of integer and string are please.
thanks
What do you mean?
Without any modifiers, everything prints in exactly the number of required characters.
If you want to change that, look up the manipulators like setw()
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
sorry if i was a bit vague. what i mean is whats the standard variable lengh of these data types in c++ or are they variable length?
ps tis for a data dictionary on my coursework btw
It's dependant on the compiler (or the OS, or both, I'm not certain, actually), but the only requirement for an int is that it's equal to or greater than a short int and less than or equal to a long int. Generally it's either 4 or 8 bytes.
A string is of course variable dependant on the length of a string. Assuming by string you mean a constant char*, then the size of the string is equal to the length of the string(plus the null) * the size of a char. A char is 1 byte.
Sent from my iPadŽ
hmmm. 8 bytes thats 8 characters???
8 characters is 8 bytes.
Sent from my iPadŽ
Ah, OK
std::string has no length limit (as far as I know), apart from the physical limits of your implementation.
Numeric types have upper and lower bound limits, see for example
http://www.unc.edu/depts/case/pgi/pg...r/num_5679.htm
http://www.opengroup.org/onlinepubs/.../limits.h.html
The 'C' standard (which C++ adopts) sets down the minimum allowed ranges for things like CHAR and INT, but an implementation is free to choose types which have a larger range.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.