sizeof continues to return 4 instead of actual size
- by Guest
#include <iostream>
using namespace std;
int main()
{
cout << "Do you need to encrypt or decrypt?" << endl;
string message;
getline(cin, message);
int letter2number;
for (int place = 1; place < sizeof(message); place++)
{
letter2number = static_cast<int>(message[place]);
cout << letter2number << endl;
}
}
Examples of problem: I type fifteen letters but only four integers are printed. I type seven letters but only four integers are printed.
The loop only occurs four times on my computer, not the number of characters in the string.
This is the only problem I am having with it, so if you see other errors, please don't tell me. (It is more fun that way.)
Thank you for your time.