+ 1
How do I use cin to assign the input as a variable?
3 Answers
+ 9
Did you mean something like tthis?
int a;
cin >> a;
+ 3
variables need to have types like interger, char, and string in c++.
Only php and js automaticaly assign types with var.
+ 3
For Example:
#include <iostream>
using namespace std;
int main (void) {
//Here's one Integer and one String
int A;
string B;
/*Here comes the input box; In the first line, the input will be assigned to "int A",
in the second line, text-input will be assigned to "string B"*/
cin >> A;
cin >> B;
//Output the Values of "int A" & "string B"
cout << A << endl;
cout << B << endl;
return 0;
}