P
Einen Teil der Antwort gibst du selber. Das Ergebnis soll ein String sein, dort wird für jedes Bit ja ein char benutzt. Wenn du diesen String schreibst und liest hast du keinerley probleme.
Bitweises Schreiben in eine Datei ist meines Wissens nicht möglich, die kleinste Einheit ist ein Byte.
Wenn du jedes Bit deiner Daten so kodierst, kannst du auch gleich einen String nehmen.
Als Vorschlag ich würde die Huffmancodierung als Integer berechnen, danach mit itoa mit der radix 2 in einn String
umwandeln und diesen String dann schreiben.
Ich hoffe dein Compiler unterstützt das Visual C++ 6.0 und Borland C tun das
char *_itoa( int value, char *string, int radix ); (steht zwar nicht im ANSII standard, gibts aber trotzdem fast
überall)
Return Value Each of these functions returns a pointer to string. There is no error return.
Parameters
value Number to be converted
string String result
radix Base of value; must be in the range 2 – 36
Remarks
The _itoa, _i64toa, and _ui64toa function convert the digits of the given value argument to a null-terminated character string and stores the result (up to 33 bytes) in string. If radix equals 10 and value is negative, the first character of the stored string is the minus sign ( – ). _itow, _i64tow, and _ui64tow are wide-character versions of _itoa, _i64toa, and _ui64toa respectively.
:p @kingruedi dein Kommentar ist bekannt und akzeptiert, wenn ich die Source finde poste ich sie hier :p
Ich finds interessant das in den letzten 3 Tagen 3 Fälle für diese Funktion aufgetaucht sind.