Last active
July 30, 2019 22:09
-
-
Save jeromew21/c09d876c294ab1c363fc47c70e188008 to your computer and use it in GitHub Desktop.
c++ cheatsheet
This file contains 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 <fstream> | |
//STUFF | |
std::ofstream fileout; | |
fileout.open("filename.txt", std::ios_base::app); | |
fileout << "hello world"; | |
//STUFF |
This file contains 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 <chrono> | |
/* | |
* ... | |
*/ | |
auto start = std::chrono::high_resolution_clock::now(); | |
/* | |
* do stuff | |
*/ | |
auto stop = std::chrono::high_resolution_clock::now(); | |
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); //or milliseconds | |
double duration_count = duration.count(); |
This file contains 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
std::string input(std::string const &message) { | |
std::string result; | |
std::cout << message; | |
getline(std::cin, result); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment