-3
我在獲取要在主函數中打印的ROBX和ROBY變量時遇到了問題。這是我的程序的一小部分,我不知道我做錯了什麼。謝謝!使用main函數中後面的函數中的變量C
#include <stdio.h>
#include <time.h>
#define ROW 8
#define COLUMN 8
int robot (int m[ROW][COLUMN], int ROBX, int ROBY);
int ROBX;
int ROBY;
int main(void)
{
printf("%d %d\n", ROBX, ROBY);
return 0;
}
int robot (int m[ROW][COLUMN], int ROBX, int ROBY)
{
// ensure different output each time program is run
srand (time(NULL));
// Pick a random spot to place the robot
int placed = 0;
int ROBX;
int ROBY;
while(placed == 0)
{
int t = rand() % ROW;
int y = rand() % COLUMN;
if(m[t][y] == 0)
{
m[t][y] = -2;
placed = 1;
ROBX = t;
ROBY = y;
}
return ROBX, ROBY;
}
}
那麼你得到的錯誤是什麼。 – Falmarri 2014-11-03 21:10:33
是不是你的程序應該在某個時候調用'robot()'函數? – 2014-11-03 21:10:44
逗號操作員如何工作? http://stackoverflow.com/questions/54142/how-does-the-comma-operator-work] – Elazar 2014-11-03 21:11:13