Beginner question help !

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
int a=0,b=0,c=0,d=0,e=0,f=0,ana=0,ste=0;
string j,k,l,m,n,o;
cin >> j >> k >> l >> m >> n >> o;
    for (int i=0;i<3;i++)
    {
        a+=j[i]-'0';
        b+=k[i]-'0';
        c+=l[i]-'0';
        d+=m[i]-'0';
        e+=n[i]-'0';
        f+=o[i]-'0';
    }
atoi(j.c_str());
atoi(k.c_str());
atoi(l.c_str());
atoi(m.c_str());
atoi(n.c_str());
atoi(o.c_str());

    if (j%a==0)
    {
        ana=ana+2;
        ste--;
    }
    if (k%b==0)
    {
        ste=ste+2;
        ana--;
    }
    if (l%c==0)
    {
        ana=ana+2;
        ste--;
    }
    if (m%d==0)
    {
        ste=ste+2;
        ana--;
    }
    if (n%e==0)
    {
        ana=ana+2;
        ste--;
    }
    if (o%f==0)
    {
        ste=ste+2;
        ana--;
    }
}


This is the code I made for a simple exercise. What doesn't work here is the atoi function. It says no match for operator %. Please help ! Thanks in advance :D
Variable 'j' (and some others) is declared having type string. class std::string has no such an operator as %. So for example your statemnet

if (j%a==0)


is incorrect. You may use only integer types with this operator in your ptogram
There is no operator % in the string-library. So what will string%int do?
To what is the atoi returned?

Topic archived. No new replies allowed.