Thread: Using files to store aint working. HELPPpp!!!!

  1. #1
    Registered User
    Join Date
    Apr 2009

    Question Using files to store aint working. HELPPpp!!!!

    I got the program to work without files but implementing files just isn't working out: could anyone help me use files with the void Add, etc format

                                        /*GLOBAL COMPUTER SCHOOl*/
                                          /*STUDENT DATABASE*/
    #include <stdlib.h>
    #include <stdio.h>
    #include <ctype.h>
    int main()
    printf("\t\t\t GLOBAL COMPUTER SCHOOL");
    struct GCS             //Declaring Global Database
           char sfname [20];
           char slname [20];
           char DOB[20];
           char mother [20];
           char father [20];
             struct GCS student[50];    //Declaring a student database under Global Database
             int scount;         //Count number of students in database
             char test = '\0';       //Tests value to cease inputs
             printf("\n*******************************************************************************\n"); /* Draw the top of the box */
             for(scount = 0; scount < 50; scount++)
    int option;
    printf("1.\tAdd Student\n2.\tDelete Student\n3.\tList Student\n4.\tEdit Students\n5.\tExit\n\n");
    printf("\nWhich do you want to do?");
    scanf("%d" , &option);
    switch (option)
                            case 4:
                                 printf("Which Student?\n");
                                 scanf("%d", &option);
                            case 5:
                                 printf("\nTHANK YOU for using the GCS...\n");                              
                            case  1:
    printf("\nAre you sure you wish to add students (y or n)?", scount? "nother ": "");
    scanf(" %c", &test);
    if(tolower(test) == 'n')
    printf("\nEnter Student's First Name: ");
    scanf("%s", student[scount].sfname);      //Reads the student's first name
    printf("\nEnter %s's Last Name: ", student[scount].sfname);
    scanf("%s", student[scount].slname);      //Read the student's last name
    printf("\nEnter %s %s DOD (mm-dd-yyyy): ", student[scount].sfname,student[scount].slname);
    scanf("%s", student[scount].DOB);       //REads the student's DOB
    printf("\nEnter %s %s Mother's Name: ",student[scount].sfname,student[scount].slname);   
    scanf("%s", student[scount].mother);      //REad PArent First Name
    printf("\nEnter %s %s Father's Name: ",student[scount].sfname,student[scount].slname);
    scanf("%s", student[scount].father);      //REad Parent Last Name
                              case 3:
    { printf("Students in GCS Database include: \nNAME:\t %s %s \nDOB(mm/dd/yyyy): %s \nParents:\t %s & %s\n", student[scount].sfname,student[scount].slname,student[scount].DOB,student[scount].mother,student[scount].father);    
    for(int i = 0 ; i<scount ; i++ )
    printf("\n\n Student: \t %s %s \n DOB (mm/dd/yyyy): %d \n Parents' Name: %s  & %s\n", student[i].sfname, student[i].slname, student[i].DOB, student[i].mother, student[i].father);
                                 printf\n"); /* Draw the bottom of the box */
    return 0;
     }          }
    Last edited by success972; 04-12-2009 at 08:17 PM.

  2. #2
    Registered User
    Join Date
    Aug 2008
    Umm... Not that I'm one of the folks you should be excited to have help from, but I'm not touching that while the indentation is all over the place. If you clean it up I can at least start getting an idea what the problem is.

    Also, do you know what part of the program is failing? What's the program's output? Does it crash anywhere?

  3. #3
    Registered User
    Join Date
    Dec 2006

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    implementing files just isn't working out:
    after you fix your indentation be also more specific in describing the problem.

    "Does not work" is not telling much. Describe what it should do , what it does and how itis different.

    Are you sure all this long code is needed to represent a problem? could you make a smaller compilable example that is focused just on the problem on hands?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Working with multiple source files
    By abh!shek in forum C Programming
    Replies: 17
    Last Post: 06-03-2008, 11:23 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  5. Dos commands hehe
    By Carp in forum A Brief History of
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM