I want to be able to get a line and split it to different types of variables (using standard c++ libraries). So this input line:
C 56 99.7 86.7 9000
Will “explode” by a space char to these variables in order:
Char
std:string
double
double
double
This is how I currently handle the given input:
#define MAX_LINE 200
char line[MAX_LINE];
cout << "Enter the line: ";
cin.getline (line,MAX_LINE);
Is there some special function like getline() i can use to separate the given input and assign these input to variables (with casting or similar)?
Use the
>>operator to get what you wantYou can read more about it here