string problem II

I have to consider two cases

P should be : Vitamin A or VitaminA

so i used get line for P;


1
2
3
4
        cin >> A >> U >> R; 
        getline(cin,P);





3500.0 iu 5000.0 Vitamin A
 Vitamin A 3500.0 iu 70%



but the there is space before Vitamin A
i think they consider space also as one string input.

i want to make it as


3500.0 iu 5000.0 Vitamin A
Vitamin A 3500.0 iu 70%


help
Does this work?:
1
2
3
4
        getline(cin,A, ' ');
        getline(cin,U, ' ');
        getline(cin,R, ' ');
        getline(cin,P);


It's not the best method, but it should work for what you want.
http://cplusplus.com/reference/iostream/manipulators/ws/
1
2
std::cin>>A>>U>>R>>std::ws;
std::getline(cin,P);
Thank you ~
Topic archived. No new replies allowed.