Split string

Hello, im beginner and i need help with one of my programs. I must chech identification number if its correct but i have no idea how split string to check it.

Input: 736028/5163
Input: 855107/7392 etd.

String will be always long like this and i must separe numbers like:
for Input: 736028/5163
string a = 73
string b = 60
string c = 28
string d = 5163

Is there any way how to do it easy ? I find some functions but they are too hard to understand for me.

Thank you for any advice :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 #include <iostream>
#include <string>
using namespace std;

int main()
{

   string Bx;
   string a, b, c ,d;
   cout << "Enter indentification number" << endl;
   cin >> Bx;
 // ??

    return 0;
}
If they are all fixed width fields:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string>

int main()
{
    const std::string input = "736028/5163" ;
    if( input.size() == 11 )
    {
        const std::string a = input.substr( 0, 2 ) ;
        const std::string b = input.substr( 2, 2 ) ;
        const std::string c = input.substr( 4, 2 ) ;
        const char seperator = input[6] ;
        const std::string d = input.substr( 7 ) ;

        std::cout << "input: " << input << '\n'
                  << "a: " << a << '\n'
                  << "b: " << b << '\n'
                  << "c: " << c << '\n'
                  << "seperator: " << seperator << '\n'
                  << "d: " << d << '\n' ;
    }
}
thank you :)
Topic archived. No new replies allowed.