F
Francesco
Hi,
I've a question...
is it possible to change the default separator in the stream operator ">>"
(for example from the blank space " " to the comma "," ) ?
Here is an example...
I want to read a sequence separated by blank space. I can do like
this...(with cin, but with file is the same thing)
2003/08/15 25 26 24.23232323
----------------------------------------
std::string data;
int val1, val2;
float r1;
std::cout << "Insert data: ";
std::cin >> name >> val1 >> val2 >> r1;
------------------------------------------
But if I've comma separated values like....????
2003/08/15,25,26,24.23232323
I know that I can use the getline where it's possible to select the
separator, but my question is only about the ">>".
With all values different from char or string I can di something like
this...
char c;
cin >> val1 >> c >> val2 >> c >> r1;
but with a string.... I don't know.
Thanks for your opinions,
Ciao, Checco.
I've a question...
is it possible to change the default separator in the stream operator ">>"
(for example from the blank space " " to the comma "," ) ?
Here is an example...
I want to read a sequence separated by blank space. I can do like
this...(with cin, but with file is the same thing)
2003/08/15 25 26 24.23232323
----------------------------------------
std::string data;
int val1, val2;
float r1;
std::cout << "Insert data: ";
std::cin >> name >> val1 >> val2 >> r1;
------------------------------------------
But if I've comma separated values like....????
2003/08/15,25,26,24.23232323
I know that I can use the getline where it's possible to select the
separator, but my question is only about the ">>".
With all values different from char or string I can di something like
this...
char c;
cin >> val1 >> c >> val2 >> c >> r1;
but with a string.... I don't know.
Thanks for your opinions,
Ciao, Checco.