dimanche 1 mars 2015

convert subsection of a string to int c++

I have a string that looks like the following:


Horizontal Binning: 4


I have the whole line stored as a string, and can access the number 4 using something like linestring[30], where linestring is the string the whole line is stored as. I am trying to access the number 4 as an integer, and not a string. How can I do this? I have tried to use atoi(linestring[30].c_str()); but this does not like having an argument to linestring. I cannot use external libraries such as boost etc. How can I do this?


Aucun commentaire:

Enregistrer un commentaire