Thread: Dummy

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    1

    Lightbulb Dummy

    What would a definition for a dummy be in C and were should it be used Thanks!

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    #define DUMMY

    I'm not totally sure what you're asking, but I think you're referring to a dummy variable. A dummy variable is just a variable that you don't need, but that you use to make the calculation more clear. You would declare it like any other variable. In the following example, time is a dummy variable
    Code:
    // calculate position: x = x0 + v0 * t + 1/2 * a * t^2
    // no dummy variable
    x = x0 + v0 * (end_time - start_time) + 0.5 * a * (end_time - start_time) * (end_time - start_time);
    Code:
    // calculate position: x = x0 + v0 * t + 1/2 * a * t^2
    // with dummy variable, much cleaner
    int    time = end_time - start_time;
    x = x0 + v0 * time + 0.5 * a * time * time;

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    A dummy variable would be used in the case a function takes for example, an out reference parameter, where the caller has no interest in that particular bit of information.

    Windows message handlers and the bHandled parameter, are a place it commonly comes up.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Quote Originally Posted by Lost.at.C View Post
    What would a definition for a dummy be in C and were should it be used Thanks!
    I think it already contains the punch line!
    (Not meant against the OP Lost.at.C, but in general. There are lots.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Circular doubly linked list with dummy header
    By mag_chan in forum C Programming
    Replies: 5
    Last Post: 10-31-2005, 08:44 AM
  2. Dummy Node
    By NavyBlue in forum C Programming
    Replies: 11
    Last Post: 10-01-2002, 02:41 PM
  3. file dummy
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 06-05-2002, 11:50 AM
  4. how to obtain first character of every other word
    By archie in forum C++ Programming
    Replies: 8
    Last Post: 02-18-2002, 01:58 PM
  5. Please help this DUMMY
    By BB2101 in forum C++ Programming
    Replies: 2
    Last Post: 11-20-2001, 02:17 PM