Hello, my question is, if you have a string of numbers, such as 12345, how can you separate the string so that your program reads each number individually?
#include <iostream>
usingnamespace std;
int Count_Index(long ,int );
int main()
{
long Number;
int index;
cout<<"Please entered the Number:"<<endl;
cin>>Number;
cout<<"Please tell which number you want (The index) :"<<endl;
cin>>index;
cout<<"the "<<index<<"rd number is: "<<Count_Index(Number,index)<<endl;
return 0;
}
int Count_Index(long Number,int index)
{
int* array=newint[10];
int remainder;
int i=0,answer=0;
while(Number!=0)
{
remainder =Number%10;
array[i]=remainder;
i++;
Number/=10;
}
answer=array[i-index];
delete array;
return answer;
}