Would there be an easier way to find and print out one number from a string without knowing the number?
For example the fifth number.
Code:#include <iostream> #include <string> using namespace std; int main() { string port1; size_t found; int port1int; string ftpmessage = " (66,220,9,50,27,99)."; found = ftpmessage.find(","); found = ftpmessage.find(",",found+1); found = ftpmessage.find(",",found+1); found = ftpmessage.find(",",found+1); for(int i=1; i<4; i++) { port1 = ftpmessage.substr(found+1,i); if (port1.find(",") != string::npos) break; } cout << "port1: " << port1 << endl; return 0; }



LinkBack URL
About LinkBacks


