i want to take rest of string from input buffer to b after using cin.ignore();
whats wrong in that?
eg: say first i entered the string "hello how are you";
at first i take first character in c then after ignoring space rest part in b ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main()
{
char c,*b;
cout<<"enter any string"<<endl;
c=cin.get();
cin.ignore(225,' ');
cin>>b;
cout<<b<<endl;
return 0;
}
It can not work. cin will not magically allocate space for you. It completely violates RAII. And no, it would only contain "how", and "are you" would still be left in cin.