我正在运行一个快速测试,以确保我的指针算术运算:
main.c中
#include <stdio.h>
#include <stdlib.h>
#define ADDRESS 0xC0DCA11501LL
#define LENGTH 5
void print_address( char *, char );
/* Main program */
int main( int argc, char *argv[] )
{
char nums[ LENGTH ];
/* LSB first */
for( int i = 0; i < LENGTH; i++ )
{
nums[ i ] = ( ADDRESS >> ( 8 * i ) ) & 0xFF;
}
print_address( nums, LENGTH );
system("PAUSE");
return 0;
}
void print_address( char *data, char len ) …Run Code Online (Sandbox Code Playgroud)