完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有下面的变量BabyCar NoMeNoT(10);未设置的TunMurnPosiv[5]=4;NoMultPosie[4]=9;NoMultPosi[3 ]=4;NoMultPoo[4 ]=9;NoMultPosi[O]=I.;NoMultPosi[O]=I.;NoMultPosi[O]=I.;NoMultPosi[y]=I.;然后我做了。NeWAtiON= ATOI(NUMLBONT);结果是0x00 00 7CBF,但我预期0xFFFF7CBFF如果我设置了No.RealPosiv4到424950495,我就得到0xFFFFEB5F,就像我预期的那样,为什么我在一个案例中得到0x000而不是0xFFFF,而另一个它工作得很好呢?
以上来自于百度翻译 以下为原文 I have the following variables char numberInput[10]; unsigned long newNumber = 0; I set numberInput to numberInput[0] = 4; numberInput[1] = 2; numberInput[2] = 9; numberInput[3] = 4; numberInput[4] = 9; numberInput[5] = 3; numberInput[6] = 3; numberInput[7] = 6; numberInput[8] = 9; numberInput[9] = 5; Then I do newNumber = atoi(numberInput); The result is 0x00007CBF but I was expecting 0xFFFF7CBF If I set numberInput to 4294950495 I get 0xFFFFBE5F like I would expect Why am I getting 0x0000 instead of 0xFFFF in one case but in the other it works fine? |
|
相关推荐
10个回答
|
|
据我所知,这不是ATOI工作的方式。首先,您需要为NUBLIN输入数组中的空终止符留出空间。接下来,试试这样的事情: 以上来自于百度翻译 以下为原文 To my understanding, that is not how atoi works. First, you'll need space for the null terminator in your numberInput array. Next, try something like this: char numberInput[11]; numberInput[0] = '4'; numberInput[1] = '2'; numberInput[2] = '9'; numberInput[3] = '4'; numberInput[4] = '9'; numberInput[5] = '3'; numberInput[6] = '3'; numberInput[7] =' 6'; numberInput[8] = '9'; numberInput[9] = '5'; numberInput[10] = ' |