I'm writing a program that inputs the amount of money and outputs it preceded by dollar sign and divided by commas into groups of three digits
I'll enter the money as string and call function called mstold()and returns an equivalent number as long double so my problem is how can I get the a number long double equivalent to string and this is my code :
long double mstold(string money)
{
long double amnt;
for(int i=0;i<money.length();i++)
{
amnt=money[i]*10+1;
}
return amnt;
}
int _tmain(int argc, _TCHAR* argv[])
{
string money;
cout<<"Enter the amount of money you want to convert to long double"; cin>>money;
cout<<"\n\namount in long double : "<<mstold(money)<<endl;
return 0;}
Thank you :)