facing error,I'm trying to convert char values is stack to int and then square them.I tried using atoi() and sscanf() but still I'm facing this error
#include <stack>
#include<iostream>
#include<cmath>
#include<string>
#include <sstream>
using namespace std;
int main(){
int n;
std::cin>>n;
long long int num = n;
while(num != 1){
stack<char>s;
string strnum = to_string(num);
for(int i=0;i<strnum.size();i++){
s.push(strnum[i]);
}
num = 0;
while(!s.empty()){
int x=0;
//sscanf(s.top(),"%d",&x);
x = atoi(s.top());
num += (x*x);
std::cout << x << std::endl;
s.pop();
}
cout<<"num is : "<<num<<endl;
}
std::cout<<1;
}