#include <iostream>
#include <string>
using namespace std;
int main()
{
char ans = 0;
string str = "";
char c = 0;
int n = 0;
while(1)
{
cout<<"Input String : ";
cin>>ws;// stream out any whitespace
getline(cin,str);
cout<<"Input the nth number : ";
cin>>n;
//Check if that n is not equals to 0 or
//smaller than that,otherwise you will corrupt str variable
if(n<=0)
{
cout<<"The nth number too small\n";
}
else
{
c = str.at(n-1);
cout<<"The nth char is : "<<c<<endl;
}
while(1)
{
cout << "Do you want to try again(y/n)? \n";
cin>>ans;
if (ans == 'y')
{
break;
}
if (ans == 'n')
{
exit(0);
}
else
{
cout<<"INVALID CHOICE"<<endl;
continue;
}
}
}
return 0;
}