char array to long

Jan Hendrik Berlin <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Hi!

Ich hab ein Programmiertechnisches Problem! Wie bekomme ich aus einem char 
array einen Long Wert?

Mein Vorschlag:

char c[4];
long l;

l=0;
l=c[0];
l=l+(c[1]*0x100);
l=l+(c[2]*0x10000);
l=l+(c[3]*0x1000000);

Nur leider funkrioniert das nicht so ganz.. Ich könnte auch einen anderen 
variablen Typ anstatt char nehmen! Muss nur genau ein Byte groß sein! (Ich 
hab ne x86_64 architektur, macht das einen unterschied?)

mfg
Jan


-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.