printing summary

This is a discussion on printing summary within the C Programming forums, part of the General Programming Boards category; Hey guys just like to ask a question how i could use the variable drinkType to access either hot or ...

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    printing summary

    Hey guys just like to ask a question how i could use the variable drinkType
    to access either hot or cold drinks depending on what they choose in the menu selection.

    To choose 1 or 2 the same function will run but i need it to just execute
    a certain part if they where to choose hot for example. If they choose cold i would need to run only the statements that print the cold and not the hot.

    Both options have to call the same function though

    Iv written a do while in my main to choose either
    1 Hot Drinks Summary
    2 Cold Drinks Summary

    if they press 1 or 2 it suppose to run the function below and print out


    Code:
    /****************************************************************************
    * Menu option #1: Display Summary
    * Allows the user to display a summary of all hot or cold drink categories
    * and items.
    ****************************************************************************/
    void displaySummary(GJCType* menu, char drinkType)
    {
    
      /*  CategoryTypePtr currentCat;
        ItemType currentItem;
        
        
        assert(menu != NULL);
        
        currentCat = menu->headCategory;
        
        while(currentCat !=NULL)
        {
            
            currentCat= currentCat->nextCategory;
        }
        print the summary of the list*/
        
       
    
    
    
    }

    Code:
    #ifndef GJC_H
    #define GJC_H
    
    /* System-wide header files. */
    #include <stdio.h>
    #include <stdlib.h>
    #include <assert.h>
    #include <string.h>
    
    /* System-wide constants. */
    #define ID_LEN 5
    #define MIN_NAME_LEN 1
    #define MAX_NAME_LEN 25
    #define MIN_DESC_LEN 1
    #define MAX_DESC_LEN 250
    #define NUM_PRICES 3
    #define HOT 'H'
    #define COLD 'C'
    #define ERRORCODE 1
    #define BUFFER_SIZE 800
    #define NC_ARRAY_SIZE 500
    #define TRUE 1
    #define FALSE 0
    
    
    typedef struct category* CategoryTypePtr;
    typedef struct item* ItemTypePtr;
    
    /* Structure definitions. */
    typedef struct price
    {
       unsigned dollars;
       unsigned cents;
    } PriceType;
    
    typedef struct item
    {
       char itemID[ID_LEN + 1];
       char itemName[MAX_NAME_LEN + 1];
       PriceType prices[NUM_PRICES];
       char itemDescription[MAX_DESC_LEN];
       ItemTypePtr nextItem;
    } ItemType;
    
    typedef struct category
    {
       char categoryID[ID_LEN + 1];
       char categoryName[MAX_NAME_LEN + 1];
       char drinkType;      /* (H)ot or (C)old. */
       char categoryDescription[MAX_DESC_LEN];
       CategoryTypePtr nextCategory;
       ItemTypePtr headItem;
       unsigned numItems;
    } drinkType;
    
    typedef struct gjc
    {
       CategoryTypePtr headCategory;
       unsigned numCategories;
    } GJCType;
    
    int commandLineArguments(int argc, char *argv[]);
    #endif

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Quote Originally Posted by bazzano
    Hey guys just like to ask a question how i could use the variable drinkType
    to access either hot or cold drinks depending on what they choose in the menu selection.

    To choose 1 or 2 the same function will run but i need it to just execute
    a certain part if they where to choose hot for example. If they choose cold i would need to run only the statements that print the cold and not the hot.

    Both options have to call the same function though
    I must not understand the question because the only answer I can come up with is

    Maybe an IF statement?

    and you seem to be beyond that type of help.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 02:13 AM
  2. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 03:20 AM
  3. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 08:10 PM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM
  5. Printing using DrawText() or TextOut()
    By Eversman in forum Windows Programming
    Replies: 1
    Last Post: 05-24-2004, 01:12 PM

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