Code:
#include <iostream>
#include <string>
int main(void)
{
std::cout << "Please enter your name: ";
std::string name;
std::cin >> name;
std::cout << std::endl;
std::cout << "Your name is " << name << "." << std::endl;
std::cout << "The size of '" << name << "' in bytes is " << sizeof(name)
<< "." << std::endl;
std::cin.get();
std::cin.get();
return 0;
}
Question
Whenever I run this program, and input a string for the variable 'name', It will always output that the size of the variable is 32 bytes. This seems rather large for a four or perhaps five character name. Is it something to do with the O/I stream? Or does it have to do with something in the string class? I'm new to C++ so any help is appreciated. Thanks.
Output for the program:
Please enter your name: Jake
Your name is Jake. The size of 'Jake' in bytes is 32.