#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct test{
char title[20];
char total[3];
} ;
int main ()
{
struct test st[5]= {
{"kim2", "100"},
{"dong", "60"},
{"hoon", "70"},
{"soo1", "100"},
{"soo2", "80"}
};
// printf("%s__%d", st[1].title, st[1].total);
int i, j;
struct test sttemp;
// char temp2[5];
for(i=0; i<=5-1; i++){
for(j=i+1; j<=5; j++) {
if( atoi(st[i].total) > atoi(st[j].total) ) {
sttemp = st[i];
st[i] = st[j];
st[j] = sttemp;
}
}
}
for(i=0; i<=4; i++){
printf("%s__%d\n", st[i].title, atoi(st[i].total) );
}
return 0;
}
컴파일 후 실행하면 general protection exception 이라고 나네요
답변 부탁드립니다 감사합니다
|