I have this problem, I try to change a char to int, but nothing happens. This is the code:
#include <iostream>
#include <vector>
using namespace std;
vector<int> m,n;
void my_f()
{
bool *quad; quad=new bool; *quad=false;
if(*quad)
{
char *v; v=new char;
bool *vv; vv=new bool; *vv=false;
while(!*vv)
{
cin >> *v;
if(*v>48 && *v<57)
{*vv=true; m.push_back((int)*v); n.push_back((int)*v);}
}
delete v; delete vv;
}
else
{
char *v,*w; v=new char;w=new char;
bool *vv; vv=new bool; *vv=false;
while(!*vv)
{
cin >> *v;cin >> *w; //input: 2 1
if(*v>48 && *v<57 && *w>48 && *w<57)
{*vv=true; m.push_back(*v); n.push_back(*w); cout <<"si";}
cout << *v << *w << endl; // output: 2 1
}
delete v; delete w; delete vv;
}
cout << m[0]<<n[0]; // output: 50 49
}
I try with this in iteration:
if(*v=='0' || *v=='1' || *v=='2' || *v=='3' || *v=='4' || *v=='5' || *v=='6' || *v=='7' || *v=='8' || *v=='9'
|| *w=='0' || *w=='1' || *w=='2' || *w=='3' || *w=='4' || *w=='5' || *w=='6' || *w=='7' || *w=='8' || *w=='9')
{...}
Also this in push_back(); :
m.push_back(*v); n.push_back(*w);
m.push_back((int)*v); n.push_back((int)*w);
m.push_back(static_cast<int>(*v)); n.push_back(static_cast<int>(*w));
And I get the same output in m[0] and n[0], the ACSII table values
This isn't duplicate because I prove all tips in this forum such as I show in down part