【发布时间】:2013-12-11 16:58:58
【问题描述】:
我会编写一个程序,通过平移向量计算点的平移。 为此,我想将我的结构返回到我的主目录:
#ifndef _STRUCT_H_
#define _STRUCT_H_
typedef struct s_result
{
int result1;
int result2;
} t_result;
#endif /* _STRUCT_H_ */
但是我有一个编译错误:
Translation.c:15:16: error: return type is an incomplete type
Translation.c: In function ‘my_translation’:
Translation.c:29:3: warning: ‘return’ with a value, in function returning void [enabled by default]
Translation.c: In function ‘main’:
Translation.c:45:12: error: void value not ignored as it ought to be
功能:
struct s_trans my_translation(char *av1, char *av2, char *av3, char *av4)
{
int x;
int y;
int tx;
int ty;
t_result s_trans;
x = atoi(av1);
y = atoi(av2);
tx = atoi(av3);
ty = atoi(av4);
s_trans.result1 = x + tx;
s_trans.result2 = y + ty;
return (s_trans);
}
int main(int ac, char **av)
{
int i;
int j;
int trans_tab[2];
t_result s_trans;
i = 0;
j = 0;
while (av[j])
{
if (av[j] == "T")
{
s_trans = my_translation(av[j - 2], av[j - 1], av[j + 1], av[j + 2]);
printf("Translation de vecteur (%d, %d)", trans_tab[0], trans_tab[1]);
}
++j;
}
}
【问题讨论】:
标签: c struct return translation