버블정렬 질문이에요
한국드립
제가
구조체를
struct game{
char id[20],pwd[20],coin[5];
};
typedef struct game game;
로설정을하였습니다
이구조체를 가지고 코인만비교하여 아이디를코인이 바뀐 순서대로 같이 따라가게 하고싶습니다
asdf:wer:123:asv:WQER:435:ASVA:QER:122
이런식으로 파일이있으면 이것을
코인만비교하여 앞에 아이디를 같이 코인과 이동하게하고싶은데 ;;너무어려워요..
소스는
#includestdio.h
#includestdlib.h
#includestring.h
#includesys/types.h
#includesys/stat.h
#includeunistd.h
#define MAX 10
struct game{
char id[20],pwd[20],coin[5];
};
typedef struct game game;
int main(void){
FILE *fd;
char buffer[1024], *input[100],*input_2;
int i=0;
int j;
game game[50];
fd= fopen(tajja.data,r);
while(!(feof(fd)))
{
fscanf(fd, %s, buffer);
}
input_2 = strtok(buffer,:);
while(input_2 != NULL){
input[i]=input_2;
i++;
input_2=strtok(NULL,:);
}
for(j=0;ji;j+=3)
{
strcpy(game[j].id,input[j+0]);
strcpy(game[j].pwd,input[j+1]);
strcpy(game[j].coin,input[j+2]);
printf(☞%s☜===☞%s☜===☞%s☜\n,game[j].id,game[j].pwd,game[j].coin);
}
fclose(fd);
return 0;
}