I have a problem. how to use cin.putback.
For example, i write a sentence "add 10 to 3"
and i want to use cin.putback to find "add" and two number.
and it should come out like this 10 + 3 = 13
You may also want to check only the significant letters. You can use string::find() to see if the thing you want is found at position zero. if (lowercase( action ).find( "sub" ) == 0) subtract();
You may also want to add in an option to give the user "help", etc.
sry i had been busy these days. I must use cin.putback and switch case in this program
I did some part of program.
The only problem in this is i cant type too many letter
for example "add 2 to 4" it will go wrong. it will work with "a 2 t 3".
This is my code
Well I haven't looked at your code too closely, and I'm very tired, but from the looks of it--I'm also not 100% sure what you're trying to do here, I need a more thorough explanation and I think there is a much simpler way using the cin.putback function to accomplish what you're doing. As far as what I'm making an assumption that this is one problem of the few, scroll down:
You said that ""add 2 to 4" it will go wrong. it will work with "a 2 t 3"."
That is because type char only holds one character, so it will stop after the first character.
You first need to fix that, so instead of char put string. At the top of your program you must also put #include <string> to include the string class.
Hope that helped, if you have further questions and want to solve this quickly toss me your Skype or AIM username and I will help.