I'm writing code that will take a string input (any combination of
digits, letters) and I need it to output the numbers.
Here is the code:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
int x,i,y;
y = 0, x = 10;
string did;
cin >> did;
for (i=0;i<13;i++)
{
if (isdigit(did[i]))
{
y = did[i];
cout<<y<<endl;
}
}
return 0;
}
My problem is the line y=did[i].
I want to get y to equall the digits in the string.
When you run it the output is some high number not the digit in the string.