only reading first digit C++

i need to multiply each number from input file;
i already got each digit of the number doing this
EACH_DIGIT=N%10;
N/=10;
but i cant seem to get M EACH_DIGIT multiply each digit to the multiplicand;
input file looks like:

78*77


and output should look like you doing multiplication on paper or by hand:

78
*77
----
546
546
-----
6006


it only reads first digit if I move EACH_DIGIT outside the do while loop;
and if I put the for loop inside the do while loop it does not seem to work well;

can you guys point out whats wrong
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
 std::string ben(std::string eric)
 {
    int a,b;
    int c=0;
    std::ifstream arith("arith.txt");
    while (getline(arith,eric)){
        std::istringstream iss(eric);{
            while (iss>>a>>b){
            }
            while (b==0){
        int job=eric.find("*");
        std::string sub= eric.substr(job+1);
        std::istringstream bib(sub);{
            int cool,hot,warm;
            bib>>cool;
            warm=cool;
            do{
            cool/=10;
            c++;
            hot=warm%10;
            warm/=10;
            }while(cool!=0);
            for (int i=c;i>=1;i--){
                   for ( c=1;c<=i;c++){
                       std::cout<<" "; 
                   }
                    std::cout<<a*hot<<std::endl; 
             }      
                    break;
            }
        }
        }
    }
    return eric;
}
Last edited on
Topic archived. No new replies allowed.