Thread: My assignment for C project

  1. #1
    Registered User
    Join Date
    Dec 2019

    My assignment for C project

    So I was kinda in a rush for my C programming and I regret for not paying attention in class. Now I'm here seeking for help ;-;

    My part is to program a booking module which includes Booking ID, today’s date, booking date, booking time, user ID, facility ID,
    Example: B1116, 5/11/2019, 10/11/2019, 10am-11am, 19WMD09123, F0001, ...

    My module must incorporate the following 3 programming concepts which are
    1. Structures
    -Include as many useful fields as you feel is necessary
    -Incorporate structure, nested structure, and array of structure into
    your program.
    2. Text file or binary file
    -Must use a mixture of text files and binary files.
    -Enhance efficiency, readability and re-usability by using functions
    whenever appropriate.
    -Include parameters where appropriate and minimize/eliminate the
    use of global variables.

    Lastly the requirements for my module must include these 4 compulsory functions listed in a menu: Add, Search, Modify and Display. The Add function should save new record(s) into the
    corresponding text/binary file, the Search function should retrieve appropriate data from the text/binary file and display it in a suitable format. The Modify function allows a user to make changes to the data. Some basic data validation should be done before saving new or modified record(s) into a file. For the Display function, it should display all the records in an appropriate tabular format.
    [Suggestion: At the start of every module run, read all data from the text/binary file
    into an array of structures. Perform the necessary processing on the array. At the end
    of the module run, write the updated array of structures back to the text/binary file.]

  2. #2
    Registered User
    Join Date
    Dec 2019
    I believe there's something to do with this code

    #include <stdio.h>#include <stdlib.h>
    #pragma warning (disable:4996)
    void main()
    	struct Booking {
    		char bookingID[5];
    		char bookingTDate[25];
    		char bookingDate[25];
    		char bookingTimeStart[4];
    		char bookingTimeEnd[4];
    		int bookingUID[10];
    		char bookingFID[5];
    	char answer, answer2;
    	bookFile = fopen("booking.dat", "ab");
    	printf("Do you want to book a facility? (Y=Yes) > ");
    	scanf("%c", &answer);
    	if (answer == 'Y' || answer == 'y')
    		do {
    			printf("Enter booking detail :");
    			printf("Booking ID		 : ");
    			scanf(" %s", &book.bookingID);
    			printf("Today's Date		 : ");
    			scanf(" %d", &book.bookingTDate);
    			printf("Booking Date		 : ");
    			scanf(" %s", &book.bookingDate);
    			printf("Booking Time		 : ");
    			scanf(" %s", &book.bookingTimeStart);
    			printf("Booking Time		 : ");
    			scanf(" %s", &book.bookingTimeEnd);
    			printf("User ID			 : ");
    			scanf(" %d", &book.bookingUID);
    			printf("Facility ID		 : ");
    			scanf(" %s", &book.bookingFID);
    			fwrite(&book, sizeof(book), 1, bookFile);
    			printf("Add next booking? (Y = Yes) : ");
    			scanf("%c", &answer2);
    		} while (answer2 == 'Y' || answer2 == 'y');
    		printf("Bye bye \n");

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  2. project assignment due tomorrow
    By parastar in forum C Programming
    Replies: 4
    Last Post: 01-23-2011, 09:12 AM
  3. Replies: 3
    Last Post: 04-26-2009, 08:54 AM
  4. Project Assignment
    By Lurker in forum A Brief History of
    Replies: 1
    Last Post: 02-28-2004, 01:12 PM
  5. your 11th & 12th grade c++ project or similar project
    By sleepyheadtony in forum A Brief History of
    Replies: 12
    Last Post: 01-13-2002, 05:14 PM

Tags for this Thread