+ 1

How do I use cin to assign the input as a variable?

4th Aug 2017, 6:24 PM
Alex Crim
Alex Crim - avatar
3 Answers
+ 9
Did you mean something like tthis? int a; cin >> a;
4th Aug 2017, 6:29 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 3
variables need to have types like interger, char, and string in c++. Only php and js automaticaly assign types with var.
4th Aug 2017, 7:06 PM
Manual
Manual - avatar
+ 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; }
4th Aug 2017, 7:52 PM
ļ¼¢ļ½—ļ¼¤ļ¼ļ¼ļ¼¦ļ½…ļ½Œļ½‰ļ½˜ ļ¼Ŗļ½ļ½Žļ½…ļ½”ļ½šļ½‹ļ½‰
ļ¼¢ļ½—ļ¼¤ļ¼ļ¼ļ¼¦ļ½…ļ½Œļ½‰ļ½˜ ļ¼Ŗļ½ļ½Žļ½…ļ½”ļ½šļ½‹ļ½‰ - avatar