[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] C++ : Konvertere fra WORD / DWORD til char (eller noget)



On Tue, Jul 18, 2000 at 08:24:05PM +0200, Thomas Rokamp wrote:
> Jeg har et problem, som formentlig viser sig at være ganske banalt. Jeg tror
> jeg har stirret mig blind på det...
> Lad mig først lige starte med en tilståelse. Jeg er ved at lave et program
> til Windows (ja, jeg ved det...). 

FY, sikket noget at sige.

> I C++. Jeg kender ikke andre grupper end
> denne (bruger også linux sometimes :o), så jeg skriver her :


> Problemet:
> 
> Jeg har en variabel "data" :
>         unsigned char data[1024];
> 
> Jeg har også en række andre variable :
>         unsigned long X1 = 0x0123;
>         unsigned long X2 = 0x1876;
>         unsigned long X3 = 0x9987;

OK.

>         doubble unsigned long X4 = 0x12348765;

Er det det vi andre ville kalde unsigned long long?

(antager ja til spøgsmålet).


> X1 til X4 skal lægges ind i rækkefølge i "data". Altså således at man kan
> pille dem ud af "data" igen uden at de ændres.
> 
> Er der en smart måde at gøre det på eller hvordan? Jeg er selv helt tom for
> idéer, så ethvert forslag er velkomment!

Shift er din ven.

Konvertering af unsigned long:

data[0] = (unsigned char) X1;
data[1] = (unsigned char) (X1>>8);
data[2] = (unsigned char) (X1>>16);
data[3] = (unsigned char) (X1>>24);

osv. osv. osv.

Og så indpakket i små søde funktioner ;)


-- 
	Christoffer


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *