07/03/20 13:06:14
#include <stdio.h>
int main ()
{
char c;
scanf("%c", &c);
if (c == 'a'); { printf("入力値はaです。"); }/*警::コードは関数をもたない*/
else if (c == 'b') { printf("入力値はbです。"); }/*エラー:elseの位置が間違ってる*/
else if (c == 'c') { printf("入力値はcです。"); }
else { printf("入力値はa,b,c以外です。") n; }/*エラー:ステートメントにセミコロン(;)がない*/
return 0;
}
と出るのですが、どうしてなのでしょうか?
if else構文の最後のelse文の「どれにもあてはまらなかった場合に行う処理」の正しい書き方がよくわからないです。