- 论坛徽章:
- 0
|
帮你顶一下,我的window XP(Home Edition)中没开发环境,没办法测试,主要用的是linux
int main( int argc, char* argv[] )
{
char szTmp1[20] = "65c136018f9dea84";
UINT64 llMsg(0),llMsgTmp(0),llTmp(0); //就只有这里用到UINT64, 前面的100多行,完全跟算法无关,建议发贴时直接改成 unsigned long long
printf( "sizeofRtn = %d\n", sizeof( llMsg ) );
memset( szTmp1, 0, 20 );
strcpy( szTmp1, "65c136028f9dea84" );
int i = 0, j = 0, k = 0;
int nRtn = 0; //这个好像没怎么用到, main返回时总是0
for( i = 19; i >= 0; i-- )
{
if( szTmp1[ i ] == 0 )
continue;
if( szTmp1[ i ] >= '0' && szTmp1[ i ] <= '9' )
{
llTmp = szTmp1[ i ] - '0';
}
else if( szTmp1[ i ] >= 'a' && szTmp1[ i ] <= 'f' )
{
llTmp = szTmp1[ i ] - 'a' + 10;
}
else if( szTmp1[ i ] >= 'A' && szTmp1[ i ] <= 'F' )
{
llTmp = szTmp1[ i ] - 'A' + 10;
}
else
{
nRtn = -1;
break;
}
if( j == 0 )
{
j = i;
printf( "j = %d\n", j );
}
printf( "llTmp = %x\n", llTmp );
printf( "szTmp1[ i ] = %c\n", szTmp1[ i ] );
llMsgTmp = 1;
for( k = 0; k < ( j - i ); k++ )
{
llMsgTmp = llMsgTmp * 16;
}
llMsg = llMsg + llTmp*( llMsgTmp );
getchar();
printf( "llMsg = %016llx\n", llMsg );
printf( "i = %d\n", i );
}
printf( "llMsg = %016llx\n", llMsg );
printf( "Out i = %d\n", i );
return 0;
}
下面是我这边运行的结果,没什么问题,不知windows 里面的结果是怎么样的.
建议在VC6中跟踪一下内存,看到底是怎么变化的,问题出在什么地方
sizeofRtn = 8
j = 15
llTmp = 4
szTmp1[ i ] = 4
llMsg = 0000000000000004
i = 15
llTmp = 8
szTmp1[ i ] = 8
llMsg = 0000000000000084
i = 14
llTmp = a
szTmp1[ i ] = a
llMsg = 0000000000000a84
i = 13
llTmp = e
szTmp1[ i ] = e
llMsg = 000000000000ea84
i = 12
llTmp = d
szTmp1[ i ] = d
llMsg = 00000000000dea84
i = 11
llTmp = 9
szTmp1[ i ] = 9
llMsg = 00000000009dea84
i = 10
llTmp = f
szTmp1[ i ] = f
llMsg = 000000000f9dea84
i = 9
llTmp = 8
szTmp1[ i ] = 8
llMsg = 000000008f9dea84
i = 8
llTmp = 2
szTmp1[ i ] = 2
llMsg = 000000028f9dea84
i = 7
llTmp = 0
szTmp1[ i ] = 0
llMsg = 000000028f9dea84
i = 6
llTmp = 6
szTmp1[ i ] = 6
llMsg = 000006028f9dea84
i = 5
llTmp = 3
szTmp1[ i ] = 3
llMsg = 000036028f9dea84
i = 4
llTmp = 1
szTmp1[ i ] = 1
llMsg = 000136028f9dea84
i = 3
llTmp = c
szTmp1[ i ] = c
llMsg = 00c136028f9dea84
i = 2
llTmp = 5
szTmp1[ i ] = 5
llMsg = 05c136028f9dea84
i = 1
llTmp = 6
szTmp1[ i ] = 6
llMsg = 65c136028f9dea84
i = 0
llMsg = 65c136028f9dea84
Out i = -1
[ 本帖最后由 antonym55 于 2007-6-13 09:58 编辑 ] |
|