iostream - STL C++

cin

Declaration

extern istream cin;

Description

The cin object is an instantiation of the input stream istream that controls the stream buffer and is used for standard input.

Header Include

#include <iostream>

Example

#include <iostream>

int main() {
	using namespace std;

	// Ask a question
	cout << "What is your favorite number?" << endl;

	// Get input
	int iNumber;
	cin >> iNumber;

	// Output a message with the input
	cout << "Your favorite number is " << iNumber << endl;

	// Keep the window open
	cin.clear();
	cin.ignore(0xFFFFFFFF, '\n');
	cin.get();
	return 0;
}

Output

cin Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.