Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,402 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,112 people online right now. Registration is fast and FREE... Join Now!




reading a file

 
Reply to this topicStart new topic

reading a file

mitchelltab
30 Sep, 2006 - 07:44 AM
Post #1

D.I.C Head
**

Joined: 13 Jul, 2006
Posts: 104


My Contributions
I'm trying to do Write a C program that displays a three option menu of: 1. Enter A Record, 2. Display List, 3. Terminate. Option 1 should ask for Last Name (character string up to 25 long), First Name (character string up to 25 long), Sex (enumerated data type of M/F), Grade (enumerated data type of A/B/C/D/F). The data should be placed in a structure and inserted into a linked list ordered by Last Name. Option 2 should list all records on the screen. Option 3 should write the linked list to a disk file and exit. When the program is invoked it should read the existing data in the disk file if it exists before displaying the menu. After options 1 and 2 are complete the menu should be displayed again.

I'm having an issues etting up the file to be read. ANd ideas this is what i have gotten so far.

CODE
#include <stdio.h>
#include <string.h>

#define FLASE 0
#define TRUE 1
#define Nlen 25

typedef struct person{
     char FName [Nlen +1];
     char LName [Nlen +1];
     char Sex;
     char Grade;
     struct person *Next;
} PERSON;

void PrintList (PERSON*);
int DeletePerson;
PERSON* InsertNode (PERSON*, PERSON*);    

main ()
{
    PERSON *STU; //TEmp pointer used to creat list
    char ANS;    //User responce
    int Len,      //Name Length
        Deleted; //True if requested item deleted
    char FName [Nlen +1];  // first name
    char LName [Nlen +1];  // lase name
    char Grade, Sex;
    FILE *fin;
     fin = fopen( "data.dat", "rw");
    
PERSON *TOP = NULL; //Initialize top list point to Null    
    
    
while (fscan(fin, %-*s %-*s %c %c\n, Nlen, STU->LName, STU->FName, STU->Sex,STU->Grade) != EOF){
      

getchar ();
getchar ();
return 0;
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 03:11AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month