如何在 C 中的函数之间传递指针数组?
How can I pass array of pointers between my functions in 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)
}
和post函数是:
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
有人知道我该如何解决这个问题吗?
谢谢!
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));
我是 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)
}
和post函数是:
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
有人知道我该如何解决这个问题吗?
谢谢!
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));