Ignoring %

If i have a number like this: 8.00%

How can I get my program to only grab 8.00 and get rid of the %?
That kind of happens automatically.
1
2
3
4
istringstream ss( "8.00%" );
float f;
ss >> f;
cout << f << endl;
Sorry I asked the question wrong. If they wanted it in this fashion. Then I have to use all these numbers for a table, but i got that part down. All I need is to get the % out of here.

Hello, and welcome to the River Bank loan calculator.
Please enter the amount of the loan: $10000.00
Please enter the annual interest rate: 8.00%
Please enter the number of payments (in months): 12


Here is what I have.
I was able to remove the "$" from the 10000.00, but I cannot remove the % from the 8.00

//Ask for the loan amount
cout<<endl<<"What is the amount of your loan?"<<endl;
cin.ignore(20,'$');
cin>>loanAmount;
//Ask for interest rate
cout<<"What is the annual interest rate on your loan?"<<endl;
cin>>anIntRate;
//Ask for number of payments
cout<<"How many payments do you want to make?"<<endl;
cin>>payments;
Last edited on
Like Duoas said, instead of directly cin >> 'ing the integer, get it through a string and parse it through a stringstream onto the int instead. That filters out all the unnecessary stuff. For full information (and how to do it), goto http://www.cplusplus.com/forum/articles/6046/.
Topic archived. No new replies allowed.