Run-Time Check Failure #2 - Stack around the variable 'A' was corrupted.
이 렇게 계속뜨는데
using namespace std;
void bubblesort(int list[], int last);
void bubbleup(int list[], int current, int last);
int main(){
int A[100];
ifstream ifman;
ifman.open("result.txt");
cout << "unsorted number: ";
for (int a = 0; a < 100; a++){
ifman >> A[a];
cout << A[a]<<" ";
}
cout << endl;
cout << "sorted number: ";
int last = 100;
bubblesort(A, last);
for (int i = 0; i < 100; i++)
cout << A[i]<<" ";
return 0;
}
void bubblesort(int list[], int last){
for (int current = 0; current < last; current++)
bubbleup(list, current, last);
return;
}
void bubbleup(int list[], int current, int last){
for (int walker = last; walker > current; walker--)
if (list[walker] < list[walker - 1]){
int temp = list[walker];
list[walker] = list[walker-1];
list[walker-1] = temp;
}
return;
result 텍스트파일에 저장된 숫자를 배열에저장하고 그 배열을 sort하는 프로그램인데
뭐가 잘못됫는지 계속저오류가뜨고..
값은맞게뜨는데 앞에 쓰레기값이 뜨는데;;
뭐가 잘못되었나요??
list[-1]
corrupted 라는거 보니까 타락했네