C++
Jump to navigation
Jump to search
hello world
- g++ -Wall hello.cpp -o hello
- if no -o specified, you get a.out
- -Wall = include extra warnings specific to C++
General
- Copy one file into another:
#include <fstream> #include <string> int main(){ //Open file for reading std::ifstream in("input.dat"); //Open file for writing std::ofstream out("output.dat"); //Temporary buffer for line read from file std::string line; while(getline(in,line)){//getline removes the newline char out<<line<<'\n'; // Appending back newline char } return 0; }
stdlib functions
- strchr() vs strrchr() - returns pointer to first and last instance of a specified character, respectively.