Thread: GetSize

  1. #1

    Question GetSize


    I am a beginner in C. I have a problem in writing the GetSize in C. Can anyone give me some hints?

    I have the following parameters.

    int getSize (Queue* the Queue)

    the function returns the number of data currently in the queue.

    How to write this or is there any reference area that I can refer?


  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002

    Divide the size of the entire queue by the size of one element on the queue. That will tell you how many elements are in the queue.

    Hope that helps,
    Jason Deckard

  3. #3
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002

    Thumbs up

    Hi there,
    maybe I am deviating from ur query but i have a slightly better Idea (I guess). Instead of using functions for getting the number of elements in ur Queue, just declare a global variable, say qsize or something, and initialize it to 0 in the beginning and when ever u add or delete elements to the queue, increment or decrement it accordingly.

    Good Luck,
    Best Wishes,
    Help everyone you can

Popular pages Recent additions subscribe to a feed