Thread: Clearing.

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    9

    Question Clearing.

    Hey all,

    Just a simple question. How do you cleasr variables from a program. Such as I am writing a Craps program in c.. and yes this is a class assignment.. and i have it working but at one part it will start running the same number over and over.. i have looked at my loops and if statments and i see nothingwrong there. so what i am wanting to know is after each "roll" is there a command that will allow you to clear that value out.

    Thanks for any assistance.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    207
    I'm not sure, but is it the same question I have?

    Can you have a look to my last one/two threads?

    I think you've figured out more than I have yet.

  3. #3
    Registered User *pointer's Avatar
    Join Date
    Oct 2001
    Posts
    74
    You mean how do you reset a variable so that the next iteration of the loop doesn't use the current value? try this:
    Code:
    baz = 0;
    for(i = 0; i < FOO; i++){
        for(j = 0; j < BAR; j++){
            /*Do stuff*/
            baz++;
        }
        baz = 0;
    }
    With that code you use the variable baz in the inner loop, and then when you exit the inner loop baz is set to 0 so that it the inner loop can start over with a fresh value.

    This was my interperetation of your question, if I'm off let me know.
    pointer = NULL

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    9
    thanks guys. This was what i was looking for i appreciate the advice...

    until next time

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Clearing Terminal
    By mrginger in forum C Programming
    Replies: 3
    Last Post: 04-15-2009, 11:58 AM
  2. Problems Clearing Portion of Screen
    By Peter5897 in forum Windows Programming
    Replies: 2
    Last Post: 05-29-2006, 03:23 AM
  3. clearing cstring
    By curlious in forum C Programming
    Replies: 4
    Last Post: 11-30-2004, 10:30 AM
  4. clearing things up
    By webturtle0 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 11-28-2002, 03:59 PM
  5. Clearing the screen
    By Shadow in forum C Programming
    Replies: 4
    Last Post: 05-23-2002, 01:40 PM