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); }
2.1m questions
2.1m answers
60 comments
57.0k users