Last active
December 11, 2015 12:28
-
-
Save tomthorogood/4600571 to your computer and use it in GitHub Desktop.
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
#include <iostream> | |
#include <string> | |
using std::cout; | |
using std::endl; | |
using std::string; | |
int main() { | |
string var1 = "butt"; | |
string var2 = "soap"; | |
string var3 = "orcs"; | |
string var4 = "cyanide"; | |
// The endl method is more C++, and is better to be in the habit of. | |
// Without 'end', all of this would be on one line. | |
cout << "Ian smells like " << var1 << endl | |
<< " but Iris smells like " << var2 << endl | |
<< " but that's okay because neither of them smell like " << var3 | |
<< " and don't get me started on emus, which remind me of " << var4; | |
// But this works almost the same | |
cout << "Ian smells like " << var1 << "\n" | |
<< " but Iris smells like " << var2 << "\n" | |
<< " but that's okay because neither of them smell like " << "\n" | |
<< " and don't get me started on emus, which remind me of " << var4 << "\n"; | |
/* The difference is that 'endl' flushes the output buffer, meaning | |
* the text will be displayed RIGHT NOW, whereas \n will only display | |
* the text after the output buffer is flushed, over which you have little | |
* control. This can be a pain if you're using output buffer to debug, and | |
* the messages are delayed and you don't actually know where your program is breaking. | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment