-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
38 lines (27 loc) · 926 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdint.h>
#include <string.h>
void* bitcpy(void* , void* , size_t);
int main() {
unsigned source = 786786786;
unsigned dest = 0;
printf( "BEFORE\n");
printf( "source : %d\n", source );
printf( "dest : %d\n\n", dest );
// copies entire source into dest
bitcpy((void*)(&dest), (void*)(&source), 8*sizeof(source) );
printf( "AFTER\n" );
printf( "source : %d\n", source );
printf( "dest : %d\n\n\n", dest );
dest = 0;
printf( "BEFORE\n");
printf( "source : %d\n", source );
printf( "dest : %d\n", dest );
// copy only the first 10 bits from the source into dest
bitcpy( (void*)(&dest), (void*)(&source), 10 );
printf( "AFTER\n" );
printf( "source : %d\n", source );
printf( "dest : %d\n", dest );
printf( "dest after bitcpy first 10 bits from the source: %d\n", dest);
return 0;
}