Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
typedef char OneByteData;
OneByteData data1, data2, data3, data4;
data1 = FourByteData & 0x000F;
data2 = (FourByteData >> 8) & 0x000F;
data3 = (FourByteData >> 16) & 0x000F;
data4 = (FourByteData >> 24) & 0x000F;
typedef unsigned char OneByteData;
OneByteData data1, data2, data3, data4;
data1 = FourByteData & 0xFF;
data2 = (FourByteData >> 8) & 0xFF;
data3 = (FourByteData >> 16) & 0xFF;
data4 = (FourByteData >> 24) & 0xFF;
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a = 0x45abcdef, i;
char b[] = {3, 4, 5, 6};
char *p;
p = (char *)&a; // typecast the 32 bit integer address to a char pointer
for(i = 0; i <= 3; i++)
{
b[i] = p[i];
}
printf("%x %x %x %x \n\n", b[0],b[1],b[2],b[3]);
getch();
return 0;
}
header .. main.h
#include <math.h>
INT indata; // integer for holding a 32bit value look at the compiler to see how to define 32bit vals
BYTE outdata[4]; // array of values assigned by convert function
BYTE convertedbyte; // converted spot byte value...
INT t;//range 0-3 or whatever....
BOOL error; // error bit
////////////////////////////////
// : CASE LOGIC DEFINITIONS : //
////////////////////////////////
#case
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef YES
#define YES 1
#endif
#ifndef NO
#define NO 0
#endif
#ifndef HIGH
#define HIGH 1
#endif
#ifndef LOW
#define LOW 0
#endif
#ifndef ON
#define ON 1
#endif
#ifndef OFF
#define OFF 0
#endif
#ifndef UP
#define UP 1
#endif
#ifndef DOWN
#define DOWN 0
#endif
#ifndef UCHAR
#define UCHAR char
#endif
#ifndef UINT
#define UINT long
#endif
#ifndef BIT
#define BIT short
#endif
#ifndef SCHAR
#define SCHAR signed int
#endif
#ifndef SINT
#define SINT signed long
#endif
#ifndef FLOAT
#define FLOAT float
#endif
/////////////////////////////////
/////////////////////////////////
convertclass.cpp
include main.h
t,indata=0;
outdata[0]=outdata[1]=outdata[2]=outdata[3]=0x00;
convert (BYTE *outdata[],INT indata)
{
*outdata[0]=(BYTE) indata;
*outdata[1]=(BYTE) (indata<<8);
*outdata[2]=(BYTE) (indata<<16);
*outdata[3]=(BYTE) (indata<<24);
return(TRUE);
}
error= FALSE;
t=0;
indata=0; //null all variables
converterbyte=0x00;
...set t val...
..set indata;
if ((error)!=(convert (&outdata[t],indata)))
{
convertedbyte= outdata[t];
// do with the outdata byte etc what you want here
// outdata[t] returned
}
else
{ supply error or recompute}
convertedbyte=(convert(&outdata[t],indata));