FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!

How to have an input in c++




Reading input by the user in the stdin is very simple, you need the following:

iostream header class
std namespace
cin

//Here's a simple program to demonstrate input a whole number from a command line

#include <iostream>
using namespace std;

int main() {
int x;
cout << "Enter a number: "; // user prompt for input
cin >> x; // if the user input is 20, it will be placed to var x";
cout << "Your inputted number is: " << x; // display the input by the user
system("pause");
}



0 blog comments below




FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.