0

Now Question is: atoi(c[i]) is dose not convert into integer? But why ? If we can convert char integer with help of atoi then why we can't convert character particular index value?

#include <bits/stdc++.h>

using namespace std;

int main() {
    //int num = 1||2||3||4||5||6||7||8||9||0;
    
    char c[100];
    int ar[50];
    cin >> c;
    //cout << strlen(c);
    for (int i = 0; i < strlen(c); i++) {
        if (c[i] >= '0' && c[i] <= '9') {
            ar[i] = atoi(c[i]);
        }
    }
}
chqrlie
  • 131,814
  • 10
  • 121
  • 189
Mohonta
  • 1
  • 1

0 Answers0