C/C++ Arena

Step 2 of 6

Reading with cin

std::cin >> reads from input, skipping whitespace, into variables of any type. No & needed.

int age;
std::string name;
std::cin >> name >> age;

std::string (from <string>) is a real string type: it grows as needed and cleans up after itself. No more buffer sizes or '\0'.

Your turn: read a name and a number of kills and print NAME got N kills.

Previous: Hello, C++ Next: std::string is easy