Im not sure if it is possible to get the size of user inputed text in bytes, i tried it and it just keeps saying 4 which is the size of the string not the text. here is my code:
ok, that works now i have yet another problem, in my code you see: if(sizeof(bytes) >= 70)
now, i entered a bunch of words and it all equaled 129 bytes, yet it goes straight to the else statement, saying that its a small amount of byts when it should be large, here is my new code:
I know i could fix this by using 2 if statements but it seems like every time i use an else statement it never works so i need to figure out why for future use.
It looks like you didn't read Framework's reply. sizeof gives the structure size of an object. It is always a constant known at compile time. Why don't you print the value of sizeof(bytes)?
I want to know the length of each characters byte that the user enters, well, hmm not that i think about it, it really seems dumb. I know getline gets the text length but what i wanted was the size of the bytes that each character entered is.
Unless you're working with some multi-byte encoding scheme (like UTF-8) all characters are 1 byte.
And even if you are working with multi-byte encoding schemes -- that is exactly the number that length() would give you anyway. length() gives you the dumb length (the number of 'chars' used). If a glyph takes multiple chars, std::string doesn't know about that. So length() is the length in chars, not in glyphs.
This takes the size of the first element in bytes instead of the size of the pointer.
EDIT: come to think of it, a multi-byte encoding scheme would use std::wstring instead of std::string so I think that sizeof(bytes[0]) would always be 1 if we don't use std::wstring.