Keyboard Input

Getting input from the keyboard via the command line #include <iostream> #include <string> #include <sstream> using namespace std; string entered_string; float my_float=0; int my_int=0; //Get input cout << "Enter something: "; getline(cin, entered_string); //Convert and display it stringstream(entered_string) >> my_float; //Will be 0 if invalid stringstream(entered_string) >> my_int; //Will be 0 if invalid if (entered_string.compare("4") […]

Read More

std::cout

Include variables and text like this: #include <iostream> std::cout << remote_client_address << " bytes received: " << bytes_received << std::endl; or #include <iostream> using namespace std; cout << remote_client_address << " bytes received: " << bytes_received << endl;  

Read More

Using console commands in code

The command line in Linux is so incredibly powerful with so many functions available to you via the OS and optional applications you can install.  It is often the easiest solution in C++ programs to just use the command line to achieve something you need doing rather than finding a harder way to do it in code and the following […]

Read More