String stream bin numbers

Hello, im begginer and I have problem with converting string to two int separated by white space. I must enter two binary numbers in one string and make sum of them and print them again as bin number but when i convert string to int i have problem with second number.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

    #include <sstream>
    #include <iostream>
    #include <string>

    using namespace std;

    int main()
    {
        string cisla;
        string cislaII; 
        int a, b;



        cout << "enter two bin numbers" << endl;


        cin >> cisla;
        getline(cin, cislaII);


    istringstream is(cisla);
    is >> a;
    cout << "number a is " << a << endl;

    istringstream ii(cislaII);
    is >> b;
    cout << "number b is " << b << endl;


        return 0;
        }


1
2
istringstream ii(cislaII);
    is >> b;


should be:

1
2
istringstream ii(cislaII);
    ii >> b;
Last edited on
damm, im stupid, thank you :)
Topic archived. No new replies allowed.