在一個函數傳遞一個INT當我得到不正確的結果:C在函數中傳遞一個int?
int recruit(int var1, int re_unit, char *char_buffer, int var2) {
int run = 1;
int int_buffer = 0;
printf("Test1 %d\n", var1);
printf("Test2 %d\n", var2);
...
}
void some_other_function(structs, struct1[]) {
int var1 = 0;
int var2 = 0;
int re_unit = 0;
char char_buffer[] = "What ever";
//strucs[1].first = 50 this is done in a other section
var1 = strucs1[1].first;
var2 = strucs1[1].first;
recruit(var1, re_unit, char_buffer, var2);
// Ind the full verstion of the program this function is called 2 times:
// The first time nothing is worng, how ever the second time, the result
// is as explaned below
//strucs[2].first = 50 // this is done in a other section
var1 = struct1[2].first;
var2 = struct1[2].first;
recruit(var1, re_unit, char_buffer, var2);
}
int main(void) {
...
}
現在的結果是, 第一次 Test1的打印:2684032,和 的Test2打印:50
第二次 測試1打印:2684032和 測試2打印:50;
他們都應該打印50
我已經測試了struct1的值[1]。首先是50它在功能上招用前。
有沒有人知道爲什麼會發生這種情況?用C的功能
請提供**實際[SSCCE](http://sscce.org)。** – 2013-02-10 03:56:00
您的變量名稱令人沮喪。 – 2013-02-10 03:56:32
'Duur [hurr] .derp = 50'? **真**? – meagar 2013-02-10 03:59:19