I'm Requested to develop a C program

This is a discussion on I'm Requested to develop a C program within the C Programming forums, part of the General Programming Boards category; Thanks for everybody. I started coding the main function, and i found a lot of difficulties in this. and here's ...

  1. #16
    Registered User
    Join Date
    May 2003

    A New STep

    Thanks for everybody.

    I started coding the main function, and i found a lot of difficulties in this. and here's the code.

    #include <stdio.h>
    // The Maximum Length of BookName is 100 Characters
    #define MAXL_BOOKNAME	100
    // The Maximum Length of BookAuthor is 50 Characters
    #define MAXL_BOOKAUTHOR	50
    // The Maximum Length of DATE is 20 Characters
    #define MAXL_DATE
    // Defining a struct (Mostly Quoted from Hammer)
    typedef struct BookRecord
    	int Book_Id;
       char Book_Name[MAXL_BOOKNAME];
       char Book_Author[MAXL_BOOKAUTHOR];
       char Book_PublishingDate[MAXL_DATE];
       /* we can use "time_t Book_PublishingDate; */
       // return true if the Book is borrowed Is it correct?
    	bool Book_Borrowed;
    } BookRecord_t; // Why using _t ? (Hammer's Code)
    void main()
       char value;
       int val;
    	printf("What Do you Want to do: ");
       printf("\n1. Encrypt The File.");
       printf("\n2. Decrypt The file.");
       printf("\n3. Add a new Book.");
       printf("\n4. Remove an Existing Book.");
       printf("\n5. Update an Existing Book.");
       printf("\n6. Exit Program.\n");
       val=Integer.parseInt(value); // Error here! how to change char to integer
       // in c?
       scanf(value, "%d"); // is this statement true to input a value?
       switch val {
       	case 1:
          	// What functions to include here?
          case 2:
          	// What functions to include here?
          case 3:
          	AddRecord() // What parameters to include?
          case 4:
          	RemoveRecord(RecordNum) // I'm not sure about the parameters
          case 5:
          	UpdateRecord(RecordNum) // also i'm not ....
          case 6:
          	exit(); // Can I use this exit function that do exist in stdlib (as
             // stumon said?)
    I included the questions and i'll be thankful if you can answer any, or add new suggestions, and here are the previous questions that still nobody answered :

    1. can I use a global list? (i.e. can encryption/decryption work for global?)

    2. Another question arose here since i should use variable length record as Mr. Rog said : While Updating a Record, what will happen if the new record is longer than the old one?

    3. What happens If I want to delete a name in a record? (i.e. can i remove or update only one field in a record?)

    4. how i can declare a primary key in C or C++?

    Waiting for Replies,

  2. #17
    Been here, done that.
    Join Date
    May 2003
    Originally posted by BadProgrammer
    do you mean that i shouldn't make a function for exiting the program? I'll search this function and understand it better, and if you can help i'll be thankful.
    The complete answer is:
    Originally posted by Hammer
    If you want your own, you could do something like my_exit() or Exit()
    or simply use the the standard exit() routine that is already defined in C by including stdlib.c. The syntax is:

    The int is passed back to the OS for error checking, normal value is 0.


Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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