我一直得到一個[鏈接器錯誤] C:\ Users etc和collect2:Id在我的程序中返回了1個退出狀態代碼錯誤,但我沒有看到任何錯誤。這是我的計劃:計算字符串中的元音和輔音的數量
#include<stdio.h>
#include<string.h>
#include<conio.h>
int main(){
int vowels = 0, cnsnts = 0;
int i, length;
char string[100];
printf("Enter sentence:");
gets(string);
length = strlen(string);
for(i = 0; i < length; i++){
switch(toUpper(string[i])){
case 'A':
vowels++;
break;
case 'E':
vowels++;
break;
case 'I':
vowels++;
break;
case 'O':
vowels++;
break;
case 'U':
vowels++;
break;
default:
cnsnts++;
}
}
printf("The number of vowels are %d.\n", vowels);
printf("The number of consonants are %d.\n", cnsnts);
system("pause");
return 0;
}
空間之前都沒有元音輔音或。 – Ghost
@Ghost以及所有非字母數字。 –