invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]| (beginner)

  atoi, c++, integer, string

When I try to compile my code this error pops out:

invalid conversion from 'int' to 'const char*'

My task is to write a program that calculates the sum of numbers with odd index.

Please don’t roast me (I’m learning how to code in c++), and give some tips how to fix it and get my code working.

#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;

int main()
    string text;
    cin >> text;

    int len = text.length(), sum = 0, number = 0, a = 0;

    for (int i = len; i > 0; i++) {
        a = text[i];
        if (i % 2 == 1) {
            number = atoi(a);
            sum = sum + number;
    cout << sum;

    return 0;

Source: Windows Questions C++