[問題] 編譯器找不到在巨集內使用的變數
開發平台(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
04/15 16:16, 2F
阿 抱歉 了解!!
只是以前被VB寵壞 冏 感覺很丟臉 >.<
※ 編輯: stero 來自: 114.34.109.62 (04/15 16:19)
→
04/15 17:02, , 3F
04/15 17:02, 3F
→
04/15 20:16, , 4F
04/15 20:16, 4F
→
04/15 21:57, , 5F
04/15 21:57, 5F
→
04/15 23:56, , 6F
04/15 23:56, 6F