指针参数麻烦 [英] pointer argument trouble

查看:62
本文介绍了指针参数麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里真的很蠢 - 我不知道问题是什么。


如何才能获得重合[i]和计数的不同值? (注意

,我认为不是正确但我不能确定这个

阶段)。


//第3名party dll头文件

externC {

APIDLL_EXPORT bool _cdecl ENGINE_GetCoinCount(uint CoinValue,ulong *

cnt);

}


//我的.cpp文件


void Help_ProductSale_CountCoins(uint coinvalue [],ulong coincount [])

{

ulong计数;

for(int i = 6; i--;)

{

ENGINE_GetCoinCount(coinvalue [i],& coincount [ i]);

ENGINE_GetCoinCount(coinvalue [i],& count);

printf(" Count%d:%d(%d)\ r \\ n \\ n,我,重合[i],数);

}

}

bool Test_ProductSale()

{

uint coinvalue [] = {5,10,20,50,100,200};

ulong coinstart [6];

Help_ProductSale_CountCoins( coinvalue,coinstart);

}


输出:

数5:0(0)

伯爵4:0(0)

伯爵3:0(0)

伯爵2:235138746(0)

伯爵1:5 (0)

伯爵0:60597997(0)

解决方案



" voidtwerp" < VO ******* @ gmail.com> skrev i en meddelelse

新闻:11 ********************** @ i39g2000cwa.googlegr oups.com ...

我在这里真的很蠢 - 我无法看清问题是什么。

如何才能在重合[i]和计数中得到不同的值? (注意
我不认为其中任何一个是正确的但我不能确定在这个阶段。)

//第三方dll头文件
externC ; {
APIDLL_EXPORT bool _cdecl ENGINE_GetCoinCount(uint CoinValue,ulong *
cnt);
}
//我的.cpp文件

无效Help_ProductSale_CountCoins(uint coinvalue [],ulong coincount [])
printf(" Count%d:%d(%d)\\\\ nn;,i,coincount [i],count);




您可能想阅读printf文档。

因为这是C ++使用std :: cout而不是


std :: cout<< 计数 << i<< : <<重合[i] ....填写休息

你自己。


对于prinf你使用%d或%i是有符号十进制整数

%u是无符号十进制整数..我记得你的类型是

UINT(unsigned int)


// eric


voidtwerp写道:

我在这里真的很蠢 - 我看不出是什么问题。

怎么能我会在重合[i]和计数中获得不同的值? (注意
我不认为其中任何一个是正确的但我不能确定在这个阶段。)

//第三方dll头文件
externC ; {
APIDLL_EXPORT bool _cdecl ENGINE_GetCoinCount(uint CoinValue,ulong *
cnt);


这个功能的实现是什么?下次发布

因为它可能是相关的...


BTW,我可以_guess_''ulong''和'uint''是,但你需要告诉我们它是什么。并且''APIDLL_EXPORT''或''_cdecl''也未定义

这里。

}

//我的.cpp文件

void Help_ProductSale_CountCoins(uint coinvalue [],ulong coincount [])
{ul / count;
for(int i = 6; i - ;)
{
ENGINE_GetCoinCount(coinvalue [i],& coincount [i]);
ENGINE_GetCoinCount(coinvalue [i],& count);
printf(" Count%d: %d(%d)\\\ r \ n,i,coincount [i],count);


如果您想打印''unsigned long''值,您需要在

格式规范IIRC中添加''l'。 br />
}
}
bool Test_ProductSale()
{/ uint coinvalue [] = {5,10,20,50,100,200};
ulong coinstart [6];
Help_ProductSale_CountCoins(coinvalue,coinstart);


输出:
数5:0(0)
数4:0 (0)
数3:0(0)
数2:235138746(0)
数1:5(0)
数0:60597997(0)



V

-

请在通过电子邮件回复时删除资金'A'

我没有回复最热门的回复,请不要问


>> void Help_ProductSale_CountCoins(uint coinvalue [],ulong coincount [])

printf(" Count%d:%d(%d)\ r \ nn" ,我,重合[i],count);



您可能想阅读printf文档。
因为这是C ++使用std :: cout而不是

std :: cout<< 计数 << i<< : <<重合[i] ....填写休息
自己。




不幸的是因为我使用eVC ++这不是一个选项 - 但是

结果即使我更改格式说明符,我也会显示支架。


Am I being really stupid here - I cant see what the problem is.

how can I be getting different values in coincount[i] and count? (note
that I dont think either is correct but I cannot be sure at this
stage).

// 3rd party dll header file
extern "C" {
APIDLL_EXPORT bool _cdecl ENGINE_GetCoinCount(uint CoinValue,ulong*
cnt);
}

// my .cpp file

void Help_ProductSale_CountCoins(uint coinvalue[],ulong coincount[])
{
ulong count;
for(int i=6;i--;)
{
ENGINE_GetCoinCount(coinvalue[i],&coincount[i]);
ENGINE_GetCoinCount(coinvalue[i],&count);
printf("Count %d: %d (%d)\r\n",i,coincount[i],count);
}
}
bool Test_ProductSale()
{
uint coinvalue[]={5,10,20,50,100,200};
ulong coinstart[6];
Help_ProductSale_CountCoins(coinvalue,coinstart);
}

output:
Count 5: 0 (0)
Count 4: 0 (0)
Count 3: 0 (0)
Count 2: 235138746 (0)
Count 1: 5 (0)
Count 0: 60597997 (0)

解决方案


"voidtwerp" <vo*******@gmail.com> skrev i en meddelelse
news:11**********************@i39g2000cwa.googlegr oups.com...

Am I being really stupid here - I cant see what the problem is.

how can I be getting different values in coincount[i] and count? (note
that I dont think either is correct but I cannot be sure at this
stage).

// 3rd party dll header file
extern "C" {
APIDLL_EXPORT bool _cdecl ENGINE_GetCoinCount(uint CoinValue,ulong*
cnt);
}

// my .cpp file

void Help_ProductSale_CountCoins(uint coinvalue[],ulong coincount[]) printf("Count %d: %d (%d)\r\n",i,coincount[i],count);



You might wanna read the the printf documentation.
Since this is C++ use std::cout instead

std::cout << "Count " << i << ": " << coincount[i] .... fill in rest
yourself.

For the prinf you use %d or %i is for signed decimal integer
%u is for unsigned decimal integer.. And i recall you type is
UINT (unsigned int)

//eric


voidtwerp wrote:

Am I being really stupid here - I cant see what the problem is.

how can I be getting different values in coincount[i] and count? (note
that I dont think either is correct but I cannot be sure at this
stage).

// 3rd party dll header file
extern "C" {
APIDLL_EXPORT bool _cdecl ENGINE_GetCoinCount(uint CoinValue,ulong*
cnt);
And what is the implemenatation of that function? Next time post it
because it might be relevant...

BTW, I can _guess_ what ''ulong'' and ''uint'' are, but you need to tell
us what it is. And, ''APIDLL_EXPORT'' or ''_cdecl'' are also undefined
here.
}

// my .cpp file

void Help_ProductSale_CountCoins(uint coinvalue[],ulong coincount[])
{
ulong count;
for(int i=6;i--;)
{
ENGINE_GetCoinCount(coinvalue[i],&coincount[i]);
ENGINE_GetCoinCount(coinvalue[i],&count);
printf("Count %d: %d (%d)\r\n",i,coincount[i],count);
If you want to print ''unsigned long'' values, you need to add ''l'' to the
format specification, IIRC.
}
}
bool Test_ProductSale()
{
uint coinvalue[]={5,10,20,50,100,200};
ulong coinstart[6];
Help_ProductSale_CountCoins(coinvalue,coinstart);
}

output:
Count 5: 0 (0)
Count 4: 0 (0)
Count 3: 0 (0)
Count 2: 235138746 (0)
Count 1: 5 (0)
Count 0: 60597997 (0)



V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


>> void Help_ProductSale_CountCoins(uint coinvalue[],ulong coincount[])

printf("Count %d: %d (%d)\r\n",i,coincount[i],count);



You might wanna read the the printf documentation.
Since this is C++ use std::cout instead

std::cout << "Count " << i << ": " << coincount[i] .... fill in rest
yourself.



unfortunately as I am using eVC++ this is not an option - however the
result I was showing stands even if I do change the format specifiers.


这篇关于指针参数麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆