字符型数据的运算一点问题
int main(){
HANDLE hFile = CreateFile("\\\\.\\PhysicalDrive1",//\\\\.\\PhysicalDrive0..D://123.txt
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,//FILE_FLAG_OVERLAPPED,
NULL);
DWORD RSize=0;
OVERLAPPED overlap;
unsigned char MBRbuf[512]={0};
memset(&overlap,0,sizeof(overlap));
overlap.OffsetHigh = (DWORD)(0*512ull / 0x100000000ull );
overlap.Offset = (DWORD)(0*512ull % 0x100000000ull );//实现偏移
ReadFile(hFile, MBRbuf, 512, &RSize, &overlap);
int startSector=454;//判断分区表存在与否的参数
int DBRsector[20]={0};
int startDBRsector;
while(MBRbuf[startSector]!=0||MBRbuf[startSector+1]!=0||MBRbuf[startSector+2]!=0||MBRbuf[startSector+3]!=0)//判断分区表项里记录起始位置的地方是否有数据,也是退出循环的判断
{
for(int i=0;i<=7;i=i+2)//按位数存放分区起始位置
{
DBRsector[i]=getTall(MBRbuf[startSector+3]);
DBRsector[i+1]=getLow(MBRbuf[startSector+3]);
startSector=startSector-1;
}
for(int i=0;i<=7;i++)
{
printf("%0X",DBRsector[i]);
//startDBRsector+=(DBRsector[i])*pow(16,i);
}
printf("\n");
printf("%d\n",startDBRsector);
memset(DBRsector,0,20);//清零保证空
startSector+=20;//前面减过4
}
这里startDBRsector+=(DBRsector[i])*pow(16,i)出现了问题,
DBRsector[i]是字符类型的数据,现在我想把这数组连接起来的数据转换为10进制的整形数值,如何实现。