@filipe
I've found that really annoying too... It is supposedly done in order to keep separate classes separate (reduce comconnusance). But it would be easy enough to have it automatically provide the power if both files are #included in either order...
@Helegurbann
If I understand you correctly, you want the user to be able to do something like input a byte value and output its binary representation. Examples:
OK, then you only need to read one char at a time from the input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <bitset>
#include <fstream>
#include <iostream>
usingnamespace std;
int main()
{
char c;
ofstream file("Binary codes.txt");
cout << "Enter a character. It's binary value will be saved to file> ";
cin.get( c );
bitset<8> binary( c );
file << binary;
file.close();
return 0;
}
Line 8 is the single character you will get from the user.
Line 12 gets that single character.
Oh, also please be careful about how you format your code. Stay away from styles that have you stick things like { } s on the the same line as other codes. And be careful about your indentation.