Created
May 19, 2017 14:36
-
-
Save ramachandrajr/1bf5c864f6b47ce5a97af9fd704f412e to your computer and use it in GitHub Desktop.
This program helps understand string initializations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Execute the program as: | |
g++ -std=c++11 file_name.cpp -o file_name | |
*/ | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
int main() { | |
string str1{}; | |
string str1IsNull = (str1 == "\0") ? "True" : "False"; | |
cout << "str1 == Null Pointer ? " << str1IsNull << endl; | |
cout << "Size of string at initialization is: " << sizeof(str1) | |
<< " bytes" << endl; | |
cout << "Size of a int is: " << sizeof(int) | |
<< " bytes" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment