Autor Beitrag
Iceonly
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Fr 26.01.07 18:24 
Ich habe ein Problem,
ich möchte 4 unsigned chars in einem unsigned int speichern, Auslesen hab ich hinbekommen, aber speichern eben nicht

Deklaration:
unsigned char key0=128,key1=129,key2=226,key3=44;
unsigned int intMem=0xFFFFFFFF;

Auslesen hab ich mit simplen shiften hinbekommen.

Wie kann ich nun die keyx in intMem bekommen? (muss ansi-c komatibel sein)
Wäre nett, wenn mir da jemand einen Tipp geben könnten. :D
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Fr 26.01.07 19:36 
auch mit shiften?

ausblenden Quelltext
1:
intMem = (key0 << 24) + (key1 << 16) + (key2 << 8) + key3;					


Keine Ahnung ob das von der Syntax her so geht, weiß sowas bei C/C++ immer net auswendig ;) Aber zumindest geht es so im Prinzip :)



MrSaint

EDIT: grad getestet, der g++ nimmts so an :)

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
Iceonly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi 5, Delphi 6, Delphi 7, Delphi 2006, Ansi-C, Java , VS 6, Realbasic 5.5
BeitragVerfasst: Fr 26.01.07 19:50 
Vielen Dank!
Klingt logisch und funktioniert!