#include <iostream.h>
int main(void){
int base;
char num;
cout<< "Enter a base: ";
cin >> base;
while((base>=2)&&(base<=10)){
}
cin>>num;
while((num-'0') < (base)) && (c>='0'){
base>=base*2+(num-'0')
cin.get>>num;
}
cout<<base;
cin.putback>>num;
return 0;
}
Clearly, this program doesn't work very well. I am in need of help. The teacher really gave us nothing that was to be in the program. Just what the coding means like what is a character, what is a loop, etc. I got that far, but now I need some help. The program is supposed to do this:
1. Convert any base into a decimal
2. Skip over anything not in the base
An example of the input and output would be like this:
Enter a base: 5
Enter a number: 3435//=5559*1
Converted value: 269
The number supposed to convert was 3431 because everything else was a non-numeric character OR a digit not in the base. As we all know, there is no "5" in base 5. Decimal 5 is represented by "10" in base 5, so we need to skip over that.
Can someone give me an explanation of what eof, putback, and get are? My teacher told us to read about it while doing the program. I tried to apply it, but probably didn't do so properly. Can someone get me a good explanation when I apply it to cin. Thanks. Any help solving my program or giving me what restrictions to put or what to alter or anything of the sort woudl be a wondrous beacon of light for me. Thanks again. Also, can someone recommend a C++ book to me or a site with a good tutorial? I have been at this for only 10 days.