打印

求助!!!!c语言函数以指针形式调用数组如何实现?

[复制链接]
8263|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
li543117|  楼主 | 2008-8-20 16:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式


此处定义的数组,在下面供函数调用,编译总是出错,尝试了很多办法还是不行,希望高手能指点一下~~~~~如果要能正常调用该数组,该如何改正或者用其他办法如何实现?小弟不甚感激~~~~

unsigned char Inputdata_1[251574]  

void Display(int addr)   //此处改成过指针的形式,但是后面没改,编译依然无法通过
{
    
    int_t i,j;
    int_t  a,b;
    TempBuffer_img[j] = addr[i*960+j+54];         

}

void mian()
{
Display(Inputdata_1)
}
 
附:编译错误提示
"main.c", line 53: cc0142:  error: expression must have pointer-to-object type
  TempBuffer_img[j] = addr[i*960+j+54];
                              ^
编译软件对此错误的解释:
Compiler Error: expression must have pointer-to-object type
Description
The expression used does not have a pointer-to-object type. 
Severity
Fatal error
Recovery
The compiler cannot recover from this error.
Example
int a;
int main()
{
return a[1]; /* Error occurs here */
}
How to Fix
Ensure that the expression used has a pointer-to-object type. The lvalue must be for a scalar, and if it is a pointer, it must point to an object.
One of the operands must have a pointer-to-object type, and the other one must be an integral expression. You can make the above example compile by either changing the declaration "int a;" to "int a[];" or by changing the return statement to "return a".
 
 

相关帖子

沙发
赤铸| | 2008-8-20 17:41 | 只看该作者

为什么非要用不同类型?

unsigned char Inputdata_1[251574]; // 楼主这里是不是少了个分号?
void Display(unsigned char * addr) // 为什么非要写成 int * ?
{
    int_t i,j;
    int_t  a,b;
    TempBuffer_img[j] = addr[i*960+j+54];         
}

void main()
{
    Display(Inputdata_1); // 强制转换编译可以通过,但必需搞清楚到底需要什么类型!
}

使用特权

评论回复
板凳
li543117|  楼主 | 2008-8-22 20:41 | 只看该作者

谢谢

感谢qinxg和赤铸的发言,受益匪浅~~~~

使用特权

评论回复
地板
ruyueyini| | 2011-5-23 16:29 | 只看该作者
感谢!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

32

主题

52

帖子

0

粉丝