c언어질문좀드릴꼐요
꽃은별
질문 제목 : 학생들의 데이터를 텍스트파일로 받아 버블 정렬 을 하는 프로그램을 짜고잇는데요
이렇게하면 텍스트파일에잇는 데이터들이 입력을 받아서 출력이되야되는데요 왜 출력이안되는거조??질문 내용 :#includestdio.h
#includestdlib.h
#includestring.h
#define max 6
int size;void bubblesort(int a[], int size)
{
int i,j,t,temp;
for(t=0;tsize;t++){
printf(%d , a[t]);
}
for(i = size-1;i0; i--) {
printf(\n %d단계,size-i);
for(j=0;j=i;j++){
if(a[j-1]a[j]){
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
printf(\n\t);
for(t=0; tsize; t++)
printf(%3d ,a[t]);
}
}
}
typedef struct student{
int b;
char name[3];
char a[10];
int phon;
char sex[1];
}student;
int main()
{
//int b[20]={0};
student std[max];
int i,count,j;
file*fp;
fp=fopen(data.txt,r);
count=0;
while(fscanf(fp,%d,&j)==1){
count++;
}
fclose(fp);
fp=fopen(data.txt,r);
for(i=0;icount;i++){
fscanf(fp,%d %s %s %d %s,&std[i].b,&std[i].name,&std[i].a,&std[i].phon,&std[i].sex);
}
printf(%d %s %s %d %s,std[i].b,std[i].name,std[i].a,std[i].phon,std[i].sex); //bubblesort(b,count);
//getchar();
fclose(fp);
}
-
새얀
그거는 파일에 데이터 수를 알려고한건데.... 그거지우고해볼께요
-
희1미햬
data 파일에 어떤게 저장됬는지 모르겠지만...
while(fscanf(fp,\%d\