Skip to content

Instantly share code, notes, and snippets.

@ramachandrajr
Created May 19, 2017 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramachandrajr/1bf5c864f6b47ce5a97af9fd704f412e to your computer and use it in GitHub Desktop.
Save ramachandrajr/1bf5c864f6b47ce5a97af9fd704f412e to your computer and use it in GitHub Desktop.
This program helps understand string initializations.
/*
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