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

This is a discussion on Using files to store aint working. HELPPpp!!!! within the C Programming forums, part of the General Programming Boards category; I got the program to work without files but implementing files just isn't working out: could anyone help me use ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    2

    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
    CODE BELOW:

    Code:
                                        /*GLOBAL COMPUTER SCHOOl*/
                                          /*STUDENT DATABASE*/
    
    #include <stdlib.h>
    #include <stdio.h>
    #include <ctype.h>
    
    int main()
    {
    printf("\t\t\t************************\n");
    printf("\t\t\t GLOBAL COMPUTER SCHOOL");
    printf("\n\t\t\t************************\n");
    
    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");                              
                                 break;
                     }
                            case  1:
                                  {
    printf("\nAre you sure you wish to add students (y or n)?", scount? "nother ": "");
    scanf(" %c", &test);
    if(tolower(test) == 'n')
    break;
                                                               
    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 */
                                 }
                                 }
    
    system("PAUSE");
    return 0;
     }          }
    
                      }
    Last edited by success972; 04-12-2009 at 08:17 PM.

  2. #2
    Registered User
    Join Date
    Aug 2008
    Posts
    129
    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
    Location
    Canada
    Posts
    3,167

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    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?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 10: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 Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  5. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 01:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21