[ back to toc ]

a simple database

Date: 2002/04/26 09:45

Q:
hi

this is the code i have to open the following text file:

*NAME-DELETED*ima,hoque,99133653,19-06-80
rachael,milor,99159357,29-05-81
carl,palmer,00214356,29-09-80
aaron,bimpson,01552336,11-02-80
louise,irving,00258654,25-03-81
helen,eckert,00214953,05-07-79
marion,laverty,98885361,25-05-78
chris,evans,99543682,04-02-80
noah,fa*NAME-DELETED*,99542364,15-10-78
lynsay,carmen,01258632,16/12/82

CODE:

#include <stdio.h>
int main()

{
FILE * fp;
int c;
fp = fopen ("student.txt", "r");
while (feof(fp)==0)
{
c=fgetc (fp);
putchar (c);
}
fclose (fp);
getchar();
}

this code works correctly. How would i allow the user to be able to
specify the first record, last record, previous record and next record?

Thank you

Rah
A:
You can compile this code to standalone executable and process the command
line arguments using the argument variables to the function 'main' called
argc, and argv. The arguments could specify the record number.

However I am afraid that this is not the asnwer for the question you
wanted to ask. I suggest that you try be more precise asking your
question.

Regards,
Peter

Hi

The text file is stored on my M drive. When the user executes the
program, they are presented with a Menu allowing them to specify to show:

All Records
First
Last
Previous
Next

All records would display the above file to the user and the above code
does this.
The problem I am finding is how can i implement the code so that the user
can specify to show only the first record or last record or previous
record and the next record.

How can the user sort the records in chronological order(the 3rd field in
my database)

Can you provide me with any help or point me in the right direction?

Thank you

Rah
Q:
A:
Well, compared to your code that reads the characters and prints them on
the screen and all the program is fourteen lines, you need a few hundred
lines of code to do what you desire.

So specifically to say:

>how can i implement the code so that the user can

you have to program it. For that you have to learn programming. I suggest
that first you target smaller issues and in a half year of study you will
be able to solve the issue you targeting right now.

Regards,
Peter

[ back to toc ]