读码笔记

  1. 字节对齐:
address_aligned = (address + ALIGN_SIZE - 1) & (~(ALIGN_SIZE - 1))
  1. 标准读取文件方式:
const char *path = _inputdata_;
FILE *fp = fopen(path, "rb");
if (!fp){
	printf("Open %s Failed!\n", path);
	return 0;
}
fseek(fp, 0, SEEK_END);
long length = ftell(fp);
fseek(fp, 0, SEEK_SET);
unsigned char *inputdata = (unsigned char *)malloc(NULL, length);
if (!inputdata){
	printf("Malloc Failed!\n");
	return 0;
}
fread(inputdata, 1, length, fp);
fclose(fp);

你可能感兴趣的:(C++学习笔记)