Thread: problems with sorting the arrays which are in already in file

  1. #1
    Registered User
    Join Date
    Nov 2002

    Exclamation problems with sorting the arrays which are in already in file

    problem with buble sort
    printf("\n  STUDENT ID  No. OF SUBJECTS  STATUS  FEES DUE\n"); printf("\n-----------------------------------------------\n");
    printf("  %d         %d            %c     $%6.2f   \n", students[i].Student_ID, students[i].nose, students[i].status, students[i].Total_fees);
    out_file = fopen("STUDENT.DAT", "a");
             if(out_file ==(FILE *) NULL)
       printf("\nFailed to open file\n");
       printf("\nSuccessfully write to the file STUDENT.\n");
        printf("\nDo you want continue?  ");
        scanf("%c", &Answer);
       while (Answer =='y' || Answer =='Y');
       fprintf(out_file,"%d %d %c %6.2f\n", students[i].Student_ID, students[i].nose, students[i].status, students[i].Total_fees);
       in_file = fopen("STUDENT.dat", "r");
       if (in_file != NULL)
       printf("\nSuccessfully open the file for reading.\n");
       printf("\nFailed to open the data file.\n");
       fscanf(in_file,"%d %d %c %f", &students[i].Student_ID, &students[i].nose, &students[i].status, &students[i].Total_fees);
       while (fscanf(in_file,"%d %d %c %f", &students[i].Student_ID, &students[i].nose, &students[i].status, &students[i].Total_fees) != EOF)
         moves = 1;
       	while (moves > 0)
                	moves = 0;
                   students[i].Student_ID= 0 ;
    while (students[i].Student_ID < 100)
                	if(students[i].Student_ID > students[i+1].Student_ID)
                   	temp = students[i+1].Student_ID;
                    students[i+1].Student_ID = students[i].Student_ID;
                      students[i].Student_ID = temp;
          for (i = 0; i< RECORDS; i++)
       fprintf(out_file,"%d %d %c %6.2f\n", students[i].Student_ID, students[i].nose, students[i].status, students[i].Total_fees);

    &#91;code]&#91;/code]tagged by Salem

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >problem with buble sort
    Yes, yes there is a problem with bubble sort.

    This is a problem too.

    Could you be more specific as to what is happening, what you want, and post some compilable code in code tags for us? Otherwise we'll just nitpick at every problem we see, driving you insane.

    My best code is written with the delete key.

  3. #3
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    First of all no one is gonna read that ?? use code tags to post ur code post it again but this time using code tages e.g of a code tag

    #include <stdio.h>
    #include <stdlib.h>
    int main()
          return 0;
    how to use code tags do this [code] your code in hear [\code]

    instead of a \ use a / i did that so i could show u the syntax of whatever
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    Are you ready for the Trix ???

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  5. archive format
    By Nor in forum A Brief History of
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM