2
假設我有int *a, int *b, int *c
並且說a
和b
已經指向一些整數。在C中添加指針的整數
我想將它們添加下來a
和b
整數,並保存到哪裏c
指向
此:
*c = *a + *b;
不起作用。它總是吐出「的無效參數‘一元*’爲什麼這麼
附加信息:? 這裏就是我正在努力實現它:
int getCoordinates(int argc, char *argv[], FILE *overlay, FILE *base, int *OVx, int *OVy, int *OVendx, int *OVendy, int *Bx, int *By, int *Bendx, int *Bendy)
{
... // OVx and OVw are assigned here. I know it works so I won't waste your time with this part.
// Set overlay image's x and y defaults (0,0).
*OVx = 0;
*OVy = 0;
...
OVendx = (*OVx) + (*OVw);
OVendy = (*OVy) + (*OVh);
它適用於我的機器。你到底有什麼問題? – 2011-03-08 00:57:43
你確定你正確地賦值嗎? [這個例子](http://ideone.com/aRFAt)工作正常。 (請注意,您必須對指針進行取消引用以查看值,您可能不會這樣做。) – 2011-03-08 00:58:57
完美地工作。發佈一個完整的例子,說明問題,以及您的預期和觀察到的行爲。 – 2011-03-08 00:59:22