0
我會製作一個程序,它通過平移向量來計算點的翻譯。 爲了這一點,我想我的結構回到我的主:爲計算翻譯的程序返回一個結構
#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;
}
}