Mega Code Archive

 
Categories / C++ / Data Type
 

String SizeOf

#include <iostream> #include <string> using namespace std; int main() {   cout << sizeof( "hello" ) << endl;          cout << sizeof( "hello there" ) << endl;    string stringObject1 = "hello";   string stringObject2 = "hello there";   cout << sizeof( stringObject1 ) << endl;             cout << sizeof( stringObject2 ) << endl;             char* s1 = "hello";   char* s2 = "hello there";   cout << sizeof( s1 ) << endl;      cout << sizeof( s2 ) << endl;      char c_arr[] = "how are you?";   cout << sizeof( c_arr ) << endl;   return 0; }