Is there a way to read multiple inputs on the same line in C# like I would in C++?
I have included an example:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
cout << "Format: name age"<< endl;
int age;
string name;
cin >> name >> age;
return 0;
}
String.Splitis the obvious solution here:Then use the resultant array.
You lose your “nice” variable names and have to convert from
stringtoint– but you’d have to do that anyway.You can specify a set of split characters: