我不斷收到第9行的語法錯誤,並分析第31,32,33和38行的錯誤......我不知道爲什麼。誰能幫我?語法和解析錯誤
#include stdio.h<> <-----there are all correct in the code but don't show on here
#include stdlib.h<>
#include math.h<>
int hamlength;
int pbit;
int hamcode;
String char *hamming = NULL;
void enter_params(){
printf("Enter length of the Hamming code:_\n");
scanf("%d",&hamlength);
printf("Enter the parity(0=even, 1=odd):_\n");
scanf("%d",&pbit);
hamming = (char *)malloc(hamlength * sizeof(char));
}
void free_memory(){
if (hamming != NULL)
free (hamming);
return;
}
1. List item
void correct_hamming(){
int errorBit=0;
int currentBit;
int i;
int j;
int k;
printf("Enter the Hamming Code:_\n");
scanf("%s", hamming);
for(i = 1, i < hamlength; i = i * 2){
for(j = i; j < hamlength; j += 2 * i){
for(k = j; k < hamlength && k < currentBit; k++){
currentBit = currentBit^hamming [hamlength - k];
if (k != i)
currentBit = currentBit^hamming[hamlength - k];
}
errorBit += ((currenttBit ^(hamming[hamlength - i] - '0')) + i);
}
}
}
int main(){
int choice=0;
while(choice!=3){
printf("1) Set parameters\n");
printf("2) Check Hamming Code\n");
printf("3) Exit\n");
printf("Enter selection:_\n");
scanf("%d",&choice);
switch(choice){
case 1: enter_params();
break;
case 2: correct_hamming();
break;
case 3: printf("dueces!");
break;
}
}
return 0;
}
'1。列表項無效C.可能是剪切粘貼錯誤,但這是「明顯」的問題。您還應該指出上述代碼中的哪些行是31/32/33/38行。 – 2011-03-17 04:30:58