organiser program

Posted on 2004-03-22
Medium Priority
Last Modified: 2010-04-15
hi, can u pleae help me with this program im tryin to solve, im an dead stuck, below i have stated the specifcation:

My task is to develop a text-based menu driven electronic organiser application   As well as its normal functions, it must also create a text file of specific records with appropriate fields for transfer of contact details to a mobile phone.

im am required to use a menu based system in the layout below:

1)      The menu.

      The menu structure will contain the following entries

•      Create an entry
•      Amend/Delete an entry
•      Search for an entry
•      Create mobile phone transfer file
•      Quit the application

Below i have listed the file processing specification for the program:
      2)      File Processing
Upon execution the application will ask for the name of the ‘master file’, which will then be supplied by the user.  All of the records in the master file will then be read into       an array before any other processing will occur.  Upon the user asking to ‘Quit’ the application, the user will be asked if the master file should be updated, but only if records have been created/amended and/or deleted.  The structure of a master file       record is as follows:
                  Surname Firstname Address_Line_1 Address_Line_2 Address_Line_3
                  Postcode Home_Number Mobile_Number Email_Address Mobile_Indicator
Each field is separated by a space and the same code given in the lectures will also allow each record to be separated by a new-line ‘\n’ character so it will be easy to create a file of test data in an editor.  One problem you will have is the presence of ‘ ‘ space characters in some of the fields.  You should assume that all fields could hold space characters and when writing out the master file replace all spaces with a field with the ‘_’ underscore character and when reading it in, replace all ‘_’ underscore characters within each field with a ‘space’ character.
When asked to generate a mobile phone transfer file, the program will ask the user for a filename, which will then be used to save the transfer data in.  Only the records with the ‘Mobile_Indicator’ set to ‘true’ will be transferred to the transfer file and only the       following fields will be transferred for each of those records:
                  Person_ID, Number
The ‘Person_ID’ is made upon of the ‘Firstname’ and  ‘Surname’ fields concatenated together with the word ‘Mobile’ or ‘Home’ appended if the ‘Mobile_number’ field or ‘Home_Number’ field is used.  Each part of the ‘Person_ID’ field will be separated by an ‘_’ underline character.  If a master record has data in both numbers then two transfer records should be created.  One for the mobile number and one for the home number. Example, one record with the mobile number will be:
            Joe_Bloggs_Mobile 0123456789

The program also has to be able to search, I have listed the search  specification below:

      3)      Internal Record Processing
            Creating a record will simply mean adding a new record to the next empty element of       the master array.  You should use the ‘strupr’ function from the <string.h> library,       which will convert all characters in a string to uppercase.  If you do this for all user       input for record fields then this will make searching for a record easier.  Use the IDE       help system to find out more about the function. Deleting a record will mean moving       all the records that follow the record to be deleted up an element so that the record to       be deleted is over-written by the next record and so on.  You should store a record in       the array as a ‘struct’ so that you can easily access all of the fields separately.
            Searching should be allowed on the following fields:
                  Surname, Post-code and/or Email Address
      I would much appreciate it you could help me, thanks
Question by:markp370
  • 4
  • 2
LVL 23

Expert Comment

ID: 10653319
What part are you having problems with?  This looks like a schoolwork assignment.
It is against the EE terms of membership for experts to do your homework for you.

We can help you overcome problems you encounter, but "im an dead stuck" is not
really a sufficient description of your problem for us to go on.


Author Comment

ID: 10653387
its not, sos im just being to detailed, it is a tutorial im doin for my degree,just for practice,the main part im havin a problem with is the part where i am asked to allow the user to input the name of the master file, where the data is be stored and implmenting it,

Author Comment

ID: 10653436
i just really need help with the structure of the program, im pretty new to programming an im finding the books i have which are the reccomended books arent helping, i am getting better but slowly as u can see,
Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.


Author Comment

ID: 10653476
i have used the example below to try and understand how to relate the menu to each part but have had no success (even though it has nothing to do with the problem):

#include <stdio.h>
#include <stdlib.h>

struct listNode {   /* self-referential structure */
   char data;
   struct listNode *nextPtr;

typedef struct listNode ListNode;
typedef ListNode *ListNodePtr;

void insert( ListNodePtr *, char );
char delete( ListNodePtr *, char );
int isEmpty( ListNodePtr );
void printList( ListNodePtr );
void instructions( void );

int main()
   ListNodePtr startPtr = NULL;
   int choice;
   char item;

   instructions();  /* display the menu */
   printf( "? " );
   scanf( "%d", &choice );

   while ( choice != 3 ) {

      switch ( choice ) {
         case 1:
            printf( "Enter a character: " );
            scanf( "\n%c", &item );
            insert( &startPtr, item );
            printList( startPtr );
         case 2:
            if ( !isEmpty( startPtr ) ) {
               printf( "Enter character to be deleted: " );
               scanf( "\n%c", &item );

               if ( delete( &startPtr, item ) ) {
                  printf( "%c deleted.\n", item );
                  printList( startPtr );
                  printf( "%c not found.\n\n", item );
               printf( "List is empty.\n\n" );

            printf( "Invalid choice.\n\n" );

      printf( "? " );
      scanf( "%d", &choice );

   printf( "End of run.\n" );
   return 0;

/* Print the instructions */
void instructions( void )
   printf( "Enter your choice:\n"
          "   1 to insert an element into the list.\n"
          "   2 to delete an element from the list.\n"
          "   3 to end.\n" );

/* Insert a new value into the list in sorted order */
void insert( ListNodePtr *sPtr, char value )
   ListNodePtr newPtr, previousPtr, currentPtr;

   newPtr = malloc( sizeof( ListNode ) );

   if ( newPtr != NULL ) {     /* is space available */
      newPtr->data = value;
      newPtr->nextPtr = NULL;

      previousPtr = NULL;
      currentPtr = *sPtr;

      while ( currentPtr != NULL && value > currentPtr->data ) {
         previousPtr = currentPtr;          /* walk to ...   */
         currentPtr = currentPtr->nextPtr;  /* ... next node */

      if ( previousPtr == NULL ) {
         newPtr->nextPtr = *sPtr;
         *sPtr = newPtr;
      else {
         previousPtr->nextPtr = newPtr;
         newPtr->nextPtr = currentPtr;
      printf( "%c not inserted. No memory available.\n", value );

/* Delete a list element */
char delete( ListNodePtr *sPtr, char value )
   ListNodePtr previousPtr, currentPtr, tempPtr;

   if ( value == ( *sPtr )->data ) {
      tempPtr = *sPtr;
      *sPtr = ( *sPtr )->nextPtr;  /* de-thread the node */
      free( tempPtr );             /* free the de-threaded node */
      return value;
   else {
      previousPtr = *sPtr;
      currentPtr = ( *sPtr )->nextPtr;

      while ( currentPtr != NULL && currentPtr->data != value ) {
         previousPtr = currentPtr;          /* walk to ...   */
         currentPtr = currentPtr->nextPtr;  /* ... next node */

      if ( currentPtr != NULL ) {
         tempPtr = currentPtr;
         previousPtr->nextPtr = currentPtr->nextPtr;
         free( tempPtr );
         return value;

   return '\0';

/* Return 1 if the list is empty, 0 otherwise */
int isEmpty( ListNodePtr sPtr )
   return sPtr == NULL;

/* Print the list */
void printList( ListNodePtr currentPtr )
   if ( currentPtr == NULL )
      printf( "List is empty.\n\n" );
   else {
      printf( "The list is:\n" );

      while ( currentPtr != NULL ) {
         printf( "%c --> ", currentPtr->data );
         currentPtr = currentPtr->nextPtr;

      printf( "NULL\n\n" );

Accepted Solution

Avik Dasgupta earned 500 total points
ID: 10660451
Hi markp370,
     If u r familiar to Linux enviornment u can use the dbm database routines and access functions to implement ur master/transaction type problem u have discussed about.

1) Make an array of stuctures like
  struct elec_org{
    char surname[20];
    char firstname[20];
  }elec[50];// say for 50 records

2) Input the file name by
     scanf("%s",filename);FILE * master;
3) read each data through from the masterfile by
  where line is a char * pointer, MAX can be #defined to ur recordlength in bytes(or no. of characters) and master is the pointer to the FILE structure for ur master file.
4) while(fgets(line,MAX,master)!=0){
      rec=1; // track the number of fields
      i=0;  // move through the record
     while(line[i]!='\n'){ // till the end of record
       while(line[j]!=' '){ // till the end of fields
          case 1: // first field
                    if(line[j]=='_'){temp[i].surname[j]=' ');}
                    else{temp[i].surname[j]=line[j]; }
          case 2: //thus for other fields
        i++;rec++; // advance to next field

Although I could'nt wrap it up nicely but I think u could have figured a bit if u would go through my code.
5)Next  comes ur routines for addition, deletion etc. Hey, wait u must now close the master file after reading.
6) any updates will straight away go to the array of structure.
 During updation u can open it in the write mode and apply a reverse processing like extracting the fields from structure array and replacing '_' by ' ' and building a string with a '\n' appended at its end and seperator between each fields. and writing that string into the master file by fputs(ln,master)
other works are pretty easy !!
Good luck


Author Comment

ID: 10660508
thanks for that help, its much appreciated, it has helped a lot, thanks


Expert Comment

by:Avik Dasgupta
ID: 10706605
Hi markp370,
          if ur really benefitted from this, then u can also help me out by accepting the answer and awarding the points.
Just a request ;)

Featured Post

Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question