[問題] 回傳字串的問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
DEV
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
string.h
問題(Question):
compile 會一直出現assignment makes pointer from integer without a cast
餵入的資料(Input):
整數
預期的正確結果(Expected Output):
字串
程式碼(Code):(請善用置底文網頁, 記得排版)
char score(int point){
char str[20];
if ((point>100) || (point<0)){
str[20]="error";
}
else if (point<=100&& point>=90){
str[20]="A";
}
else if (point<90 && point>=80){
str[20]="B";
}
else if (point<80 && point>=70){
str[20]="C";
}
else if (point<70 && point>=60){
str[20]="D";
}
else if (point<60){
str[20]="E";
}
return str[20];
}
int main()
{
int a;
char str[20];
scanf("%d",&a);
str[20]=score(a);
printf("%s\n",str);
system("PAUSE");
return 0;
}
我試了很久不知道問題出在哪....我才剛開始學
謝謝!!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.77.166
→
10/04 20:33, , 1F
10/04 20:33, 1F
→
10/04 20:34, , 2F
10/04 20:34, 2F
→
10/04 20:35, , 3F
10/04 20:35, 3F
→
10/04 20:36, , 4F
10/04 20:36, 4F
→
10/04 20:36, , 5F
10/04 20:36, 5F
→
10/04 20:36, , 6F
10/04 20:36, 6F
→
10/04 23:24, , 7F
10/04 23:24, 7F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章