I have this code it is working but if I change the string from 60pbm to bpm60 does not work. My input string is bpm60? Can any one advice how to get it or what is the be way to have the value of the int (60) only if I have pbm60???
Are you trying to make your code work for both 60bpm and bpm60 or just bpm60?
In either case you can probably use string::find() to locate where "bpm" is located in the string. If it is located starting at the first element you can use the substr() function to retrieve the numeric part of the string to be converted. If it is not at the start of the string then you should be able to use either a stringstream to process the string or stox().