這是一個簡單的測試程序,我試圖獲取函數func函數來修改變量a和b,然後在主函數中使用它們。有沒有辦法獲得func返回修改後的變量,以便可以使用? (最好不使用結構,因爲我不知道它是如何工作)獲取子函數來修改變量
#include <stdio.h>
void func(int a, int b)
{
a=a+1;
b=b+1;
}
void main(void)
{
int a=0, b=0;
while (1)
{
func(a,b);
printf("%d\n",a);
}
}
您需要[指針](http://en.wikipedia.org/wiki/Pointer_(computer_programming))。 –