🔒 Closed File modifying and deleting

Status
Not open for further replies.
Yan. Pag-aralan mo sana mabuti. Yun lang wish ko. Para hindi ka malugi kapag defense niyo na.
Error in dl8 best and worst even in show all
 

Attachments

  • IMG20181012000830_1.jpg
    IMG20181012000830_1.jpg
    313.5 KB · Views: 0
  • IMG20181012002043.jpg
    IMG20181012002043.jpg
    134.5 KB · Views: 0
  • IMG20181012002135.webp
    IMG20181012002135.webp
    218.6 KB · Views: 14
  • IMG20181012002147.jpg
    IMG20181012002147.jpg
    150.2 KB · Views: 0
Error in dl8 best and worst even in show all
Code:
void SetStudentData()
{
    int index = 0;
    int c;
    f = fopen("Record.txt", "r");

    if(f == NULL)
    {
        printf("The file is not existing...");
    }
    else
    {
        while ((c = fgetc(f)) != EOF)
        {
            ungetc(c, f);
            fscanf(f,"%s",studentList[index].id);
            fscanf(f,"%s",studentList[index].name);
            fscanf(f,"%s",studentList[index].course);
            fscanf(f,"%d",&studentList[index].year);
            for(int i = 0; i < 3; i++)
            {
                fscanf(f,"%lf",&studentList[index].score[i]);
                fscanf(f,"%lf",&studentList[index].total[i]);
                fscanf(f,"%lf",&studentList[index].grade[i]);
            }
            fscanf(f,"%lf",&studentList[index].fgrade);
            index++;
        }
        for(int i = 0; i < SIZE; i++)
        {
            if(strcmp(studentList[i].name, "") != 0)
            {
                sizeOfArray++;
            }
            else
            {
                break;
            }
        }
    }
    fclose(f);
}
 
Code:
void SetStudentData()
{
    int index = 0;
    int c;
    f = fopen("Record.txt", "r");

    if(f == NULL)
    {
        printf("The file is not existing...");
    }
    else
    {
        while ((c = fgetc(f)) != EOF)
        {
            ungetc(c, f);
            fscanf(f,"%s",studentList[index].id);
            fscanf(f,"%s",studentList[index].name);
            fscanf(f,"%s",studentList[index].course);
            fscanf(f,"%d",&studentList[index].year);
            for(int i = 0; i < 3; i++)
            {
                fscanf(f,"%lf",&studentList[index].score[i]);
                fscanf(f,"%lf",&studentList[index].total[i]);
                fscanf(f,"%lf",&studentList[index].grade[i]);
            }
            fscanf(f,"%lf",&studentList[index].fgrade);
            index++;
        }
        for(int i = 0; i < SIZE; i++)
        {
            if(strcmp(studentList[i].name, "") != 0)
            {
                sizeOfArray++;
            }
            else
            {
                break;
            }
        }
    }
    fclose(f);
}
Ito last problema paps kapag nag add ako ng new student then click ko show all or show best or worst di sya makita anyare?
 
Ito last problema paps kapag nag add ako ng new student then click ko show all or show best or worst di sya makita anyare?
Sa tingin ko nagawan na kita ng pabor. Ikaw na maghanap kung ano mali. Nahanap ko kung alin.
Kung naitindihan mo ang flow ng program. Malalaman mo saan ang mali.
 
Ito last problema paps kapag nag add ako ng new student then click ko show all or show best or worst di sya makita anyare?
May kulang na isang line sa addstudent. Kaya nagkakaroon ng logical error.
Isipin mo, kapag nag-aadd ng student ano ang naiincrement?
 
Status
Not open for further replies.

About this Thread

  • 51
    Replies
  • 2K
    Views
  • 6
    Participants
Last reply from:
Jannelle345

Trending Topics

Online now

Members online
472
Guests online
3,191
Total visitors
3,663

Forum statistics

Threads
2,305,970
Posts
29,168,832
Members
1,195,530
Latest member
grinchx8
Back
Top