1.) Don't #include <iostream.h>, #include <iostream>. That's standard C++.
mmk. I think that should fix the need for -Wno-deprecated too.
2.) Why are you using ASCII literals (0x30, 0x31) as characters? '0' and '1' work fine.
Oops, my attempt to do that was with double quotes.
3.) Why are you using printf() in a C++ program? Use cout. (Unless you're formatting strings).
Uh, hehe. *fix*
4.) accum = accum - sub; == accum -= sub;
Yeah, I was having trouble with that. I'll check it out again.
5.) You shouldn't put programming statements on the same line as I/O (IMO), for example: cin >> accum; if (accum) dosomething(); -- I think that's ugly.
I tend not to, but its much easier to follow in that particular instance, and looks cleaner. But usually, yeah, its ugly.
6.) You should have come up with a better way to do what you did in the first program. What if your project manager wanted you to convert 32-bit numbers? Can you imagine typing out all those literals? Or even macros? [edit]Hrm, your third go was better, but you still could have done better with it. Why not just cin to an int and test for 1 or 0? (Note that my program tested for illegal values also -- what would yours do if I put in a 2 or something?)[/edit]
If I had to convert a 32-bit number, I'd edit my program to allow that. If I had intended this to be distributed (in which case I should be shot =p), I would allow that, though. If you put a 2 in my program, 2!=1 so it would mistake it for a 0.