#define rows 2 #define cols 2 #define NUM_CORNERS 4 int main(void) { int i; int the_corners[NUM_CORNERS]; int array[rows][cols] = {{1, 2}, {3, 4}}; corners(array, the_corners); for (i = 0; i < 4; i++) printf("%d\n", the_corners[i]); } int corners (int array[rows][cols], int the_corners[]) { the_corners = { array[0][cols-1], array[0][0], array[rows-1][0], array[rows-1][cols-1] }; }
は、私はこれらの奇妙なエラーを取得し、私はその理由は考えていません:メインは、「あなたの機能について知っているdoesnのGCCはなぜ "表現を期待する"のですか?
prog.c: In function ‘main’:
prog.c:10: warning: implicit declaration of function ‘corners’
prog.c: In function ‘corners’:
prog.c:15: error: expected expression before
外部リンクを使用するのではなく、ここにコードを貼り付けてください。 – razlebe
次回は大丈夫です。 – tekknolagi
すべての#def定数に大文字を使用することをお勧めします。人々は通常、小文字のもの、特に関数でない場合はプリプロセッサのマクロ/定数であるとは考えていません。 – ThiefMaster