Thursday, September 14, 2006

splitting strings in c++ using stringstream

of if you need to split a string "10 20 30 40 " in c++

You can do that using istringstream

all u need to do is

#include < sstream >

Assuming s is "10 20 30 40"

istringstream iss(s) ;

int ten , twenty , thirty , forty ;
iss >> ten >> twenty >> thirty >> forty;

No comments: