How to achieve scanf("%d # %d",&a,&b);sort of effect with cin in C++ ?
scanf("%d # %d",&a,&b);
cin
You can skip the # by extracting it into a character:
#
std::istringstream iss("10 # 20"); int main() { int a, b; char hash; iss >> a >> hash >> b; assert(a == 10 && b == 20); }
548k questions
547k answers
4 comments
86.3k users