C++ Commands
The C++ language, standard library and compilers.All C++ pages
- c++ convert string to int: std::stoi vs std::from_charsConvert a std::string to int in C++ with std::stoi (throws invalid_argument or out_of_range) or C++17 std::from_chars (no exceptions). Trailing text and bases.
- c++ read a file line by line with std::getline and ifstreamRead a file line by line in C++ with std::ifstream and while (std::getline(file, line)). Check the open, strip Windows line endings, and avoid the eof() trap.
- c++ split a string by delimiter (getline, find, std::views::split)Split a string by a delimiter in C++ with a getline loop, find and substr, or C++20 std::views::split. How each treats empty fields, and splitting on spaces.
- g++ main.cpp -o main: compile and run a C++ programCompile and run a C++ program with g++ main.cpp -o main. Pick the standard with -std=c++20, enable warnings and optimization, and read compile and link errors.