如何在C中的函数之间传递指针数组?

时间:2015-05-25 09:57:57

标签: c oracle-pro-c

我在C和PRO * C中比较大,需要一些帮助。我的结构如下:

  typedef struct pt_st{
   char (*s_no)[100];
   char (*s)[100];
    } pt_st;

我有一个像c_info这样调用post函数的函数:

int c_info(pt_st ir_st)
{
int   li_result = 0;
li_result = post(ir_st.s_no)
} 

和帖子功能是:

int post(char *is_st)
{
//do something
}

当我编译程序时,我得到三个错误:

warning: passing arguments post from incompatible pointer type
warning: passing arguments post make integer from ponter without cast
warning: passing arguments post make ponter from integer without cast

有人知道如何解决这个问题?

谢谢!

1 个答案:

答案 0 :(得分:2)

pt_st.s_no以及pt_st.s都声明指向char数组的指针。

因此函数post()需要这样,例如:

int post(char (*s_no)[100]);

如果无法更改int post(char * is_st)的显示定义,请按以下方式调用:

pt_st s = ... /* some initialisation */

int result = post(*(s.s_no));
相关问题