Skip to content

Instantly share code, notes, and snippets.

@ninjapanzer
Last active February 13, 2016 20:02
Show Gist options
  • Select an option

  • Save ninjapanzer/aa9cdd6f0d6a34d1f0df to your computer and use it in GitHub Desktop.

Select an option

Save ninjapanzer/aa9cdd6f0d6a34d1f0df to your computer and use it in GitHub Desktop.
Use pointers to alias std::cin and std::cout
#include <iostream>
int main() {
// Create a std::istream pointer and assign it where cin is bound
std::istream *in;
in = &std::cin;
// Create a std::ostream pointer and assign it where cout is bound
std::ostream *out;
out = &std::cout;
std::string word;
// Dereference the pointer to access the original variable
*in >> word;
*out << word;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment