アプリ版:「スタンプのみでお礼する」機能のリリースについて

以下のようなコンパイルエラーがでます。原因がわからず困っています。

エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0xff)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0xfe)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '#' (0x23)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2141 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 宣言の構文エラー
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2206 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: 不正な文字 '' (0x0)
エラー E2228 c:\users\17042\desktop\c言語\評価課題\hyouka2.c 1: エラーあるいは警告が多すぎる
*** 26 errors in Compile ***


インデントを開けても詰められてしまうので読みにくいかとは思いますが、お願い致します。
実際のコードです↓
#pragma warning(disable:4996)
#include <stdio.h>
#include <stdlib.h>/*for atoi*/
#include <ctype.h>/*for isdigit*/
#include <conio.h>/*for getch*/

int isChar(char* s);
int inputScore();
void inputName();
void showResult(int, int, double,int);
int outOfBaunds(char*); //文字制限判定メソッド

char name[120] = {'\0'};


int isChar(char* s) {
for (;*s != '\0';s++) {
if (!isdigit(*s)) {
return 1;
}
}
return 0;
}

int outOfBaunds(char* a) {
int count = 0;

for (int i = 0; name[i] != '\0'; i++) {
count++;
}

if (count <= 21) {
return 1;
}
else {
return 0;
}
}

void showResult(int max, int min, double avg, int count) {
printf("---------------------------------\n");
printf("最大値%d\n", max);
printf("最小値%d\n", min);
printf("平均値%.1f(平均件数:%d)\n", avg, count);
}

void inputName() {

int judge = 1;
while (judge) {
printf("名前を入力>>>");
scanf("%s", &name);

if (outOfBaunds(*name)) {
judge = 0;
}
else {
printf("Over capacity\n");
}
}
}

int inputScore() {
char in[64] = { '\0' };
int score = 0;
int rangeMin = 0;
int rangeMax = 100;
int endCode = 999;
while (1) {
printf("数値を入力>>>");
scanf("%s", &in);
printf("\n");
if (!isChar(in)) {
score = atoi(in);
}
else {
printf("InputMismatchException\n");
continue;
}

if (score < rangeMin || (score > rangeMax && score != endCode)) {
printf("ValueOutOfBoundsException\n");
continue;
}
break;

}
return score;
}

void main() {
int endCode = 999;
int score = -1;
int max = 0;
int min = 100;
int sum = 0;
int count = 0;
double avg = 0;


inputName();
score = inputScore();
max = score;
min = score;

while (score != endCode) {
inputName();
if (score > max) max = score; //最大値判断
if (score < min) min = score; //最小値判断
sum += score;
count++;
score = inputScore();
}

if (count != 0) {
avg = sum / count;
showResult(max, min, avg,count);
}
else {
printf("入力データがありません");
}
}

A 回答 (2件)

>不正な文字 '' (0xff)


>不正な文字 '' (0xfe)
>不正な文字 '#' (0x23)
>不正な文字 '' (0x0)
>不正な文字 '' (0x0)

ソースコードを保存するときに、UTF-16で保存したのでしょう。
最初の2つはBOM。
0x0が出てきているので1文字が16BitになるUTF-16かと。

テキストエディタで保存するときに、BOMなしのUTF-8にするかShiftJISで保存しましょう。
    • good
    • 1
この回答へのお礼

助かりました

エラーでなくなりました!ありがとうございます

お礼日時:2022/07/12 10:16

●全てのメッセージに...hyouka2.c 1: ...とありますから「ソースファイルの一行目」を指摘されています。

ところがご開示のソースコード1行目にはスペースも日本語コードも見当たりません。
つまりご提示の内容だけでは判別できないのですが、スペースが全角文字になっていないでしょうか。

●ここに同じような例を見つけました...

https://oshiete.goo.ne.jp/qa/2808866.html

ただし、このご質問者はちゃんと...

C:\test2>bcc32 test1.exe

自分の間違った点もちゃんと書いてくれています。
この類のエラーは多く場合オペレータのかなり基本的な勘違いだと思われますので、もう一度ご自身の作業を、落ち着いて検証してみるべきだと思います。
    • good
    • 1

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!