|
- #include <stdio.h>
- #include <stdlib.h>
- void data_cleaning(unsigned char* data, int length ){
- unsigned char* abc = data;
- int total_length = length;
- int i = 0;
- int temp_length = 0;
- int j = 0;
- for(i=0; i<=total_length; i+=temp_length ){
- temp_length = strlen(abc);
- for(j=0; j<temp_length; j++) {
- printf("%2x ", abc[j]);
- }
- temp_length = strlen(abc)+1;
- abc += temp_length;
- }
- }
- int main(){
- int m = 0;
- unsigned char a[] = {0x00,0xAC,0x33,0x64,0x14,0xAB,0x00,0x80,0x64,0x14,0xAB,0x00,0x5C,0x64,0x14,0xAB,0x00,0x5C,0x00,0x55};
- for(m=0; m<19; m++) {
- printf("%2x ", a[m]);
- }
- printf("\n");
- data_cleaning( a, sizeof(a) );
- return 0;
- }
复制代码
专门在数组的头和尾部加了0x00,检验下边界值
|
|