[問題] 編譯器找不到在巨集內使用的變數

看板C_and_CPP作者 (認真 發呆)時間11年前 (2013/04/15 16:11), 編輯推噓2(204)
留言6則, 6人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) dev c++ 再重新練習C CODE 照書本的 SELECT SORT 來寫 程式碼如下 #include <stdio.h> #include <math.h> #include <stdlib.h> #define Max_Size 101 #define SWAP(x , y , z) ((z) = (x), (x) = (y), (Y) = (Z) ) void sort(int [], int); int main(void) { int i,length; int list[Max_Size]; printf("Enter the number of numbers to generate"); scanf("%d", &length); if (length<1 || length> Max_Size){ fprintf(stderr,"please < 101"); return 0 ; } for (i = 0; i<length; i++) { list[i] = rand() % 1000 ; printf("%d", list[i]) ; /*====*/ } sort(list,length); printf("\n"); getchar(); return 0 ; } void sort(int list[],int length1) { int c1,c2,min,temp; temp = 0; for (c1=0;c1<length1;c1++){ min = c1 ; /*!! */ for (c2 = c1+1 ; c2<length1;c2++) { if(list[c2]<list[min]) { min = c2; SWAP(list[c1],list[min],temp); /*SWAP這行出問題*/ } /*-----------------!! */ } } } 他出現的訊息是 我的 Y Z並未宣告定義 是在定義巨集時 還需要先定義 裡面的參數嗎? 錯誤訊息如下 In function `void sort(int*, int)': 'Y' undeclared (first use this function) (Each undeclared identifier is reported only once for each function it appears in.) `Z' undeclared (first use this function) 還請各位前輩高手 指點一下 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.109.62 ※ 編輯: stero 來自: 114.34.109.62 (04/15 16:12)

04/15 16:13, , 1F
變數名大小寫有差
04/15 16:13, 1F
對不起 我真是一整個阿呆 感謝您的幫忙 晚點自山 ※ 編輯: stero 來自: 114.34.109.62 (04/15 16:15)

04/15 16:16, , 2F
喂喂喂等一下!這個版不能自己砍文章的0.0!
04/15 16:16, 2F
阿 抱歉 了解!! 只是以前被VB寵壞 冏 感覺很丟臉 >.< ※ 編輯: stero 來自: 114.34.109.62 (04/15 16:19)

04/15 17:02, , 3F
要寫程式就不要用dev 了吧
04/15 17:02, 3F

04/15 20:16, , 4F
請問 有推薦的嗎?
04/15 20:16, 4F

04/15 21:57, , 5F
orwell,google"dev c++"排下面一點而已
04/15 21:57, 5F

04/15 23:56, , 6F
codeblocks
04/15 23:56, 6F
文章代碼(AID): #1HQxOlIf (C_and_CPP)