0
爲什麼下面的代碼不被編譯?爲了簡便起見,我想代碼寫入以這種方式,這似乎語法OK,但Linux的GCC編譯器抱怨同時實例化函數和變量初始化
#include <stdio.h>
void fn(int in, char ch, char* str);
int main()
{
fn(int i2 = 20, char ch2 = 'Z', char* str2 = "Hello");
printf("in2 = %d, ch2 = %c, str2 = %s\n", in2, ch2, str2);
return;
}
void fn(int in, char ch, char* str)
{
printf("int = %d\n", in);
printf("ch = %c\n", ch);
printf("str = %s\n", str);
return;
}
即使在C99(也是ANSI C)中,不能在表達式內部聲明... – 2010-11-25 18:59:00