C言語で配列の内容をソートするコードで以下のエラーメッセージが発生しました。
原因または解決策をご存知の方はいらっしゃいませんか。
エラーメッセージ
Run-Time Check Failure #2 - Stack around the variable 'test' was corrupted.
該当のソースコード
C
1#include <stdio.h> 2#define NUM 5 3 4 5int main(void) 6{ 7 int test [NUM]; 8 int tmp; 9 int i, j, s, t; 10 11 12 printf("%d人の点数を入力してください\n",NUM); 13 for (i = 0; i < NUM; i++); { 14 scanf("%d", &test[i]); 15 } 16 for (s = 0; s < NUM-1; s++); { 17 for (t = s + 1; t < NUM; t++) { 18 if (test[t] > test[s]){ 19 tmp = test[t]; 20 test[t] = test[s]; 21 test[s] = tmp; 22 23 } 24 } 25 } 26 27 for (j=0; j < NUM; j++) { 28 printf("%d番目の人の点数は%dです。\n",j+1,test[j]); 29 } 30 return 0; 31}
試したこと
配列"test"の領域の確認
ソリューションのリビルド
補足情報
OS:Windows10
メモリ量:8GB
エディタ:Visual Studio 2019

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。