String to int

string mystr (“1204”);
int myint;
stringstream(mystr) >> myint;

 

Float to int

int i;
float f = 3.14;
i = (int) f;

 

String to float

string s = "3.1456";
float f = atof (s);
Trackback

no comment untill now

Sorry, comments closed.