FAQ Part 3: Input/Output

How do you use input and output in C++?

  • Output: cout <<
  • Input: cin >>

Example:

int age;
cin >> age;
cout << "Age: " << age;

How is printf different from cout?

  • printf: C-style, requires format specifiers
  • cout: Type-safe, stream-based, C++-style