levelnum = 1; wont change to levelnum = 2;

This is a discussion on levelnum = 1; wont change to levelnum = 2; within the C++ Programming forums, part of the General Programming Boards category; Hey. I'm trying to make it so when my program starts levelnum is set to 1 (levelnum = 1 and ...

  1. #1
    WhiteTiger
    Guest

    levelnum = 1; wont change to levelnum = 2;

    Hey. I'm trying to make it so when my program starts levelnum is set to 1 (levelnum = 1 and later in the program it changes to 2(levelnum = 2 but it wont change. I've tried everything I can think of but it doesn't work.. help?

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Can you show your code?

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    You don't do this, right?
    Code:
    while(Looping)
    {
       LevelNum = 1;
    
       ... //The rest of the code
    
       LevelNum = 2;
    }


    Other than that, it is hard to guess without some source.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    or perhaps levelnum is a const.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Are you running into a 'scope' issue, i.e. changing 'levelnum' in a function after declaring it elsewhere, like main()?

    Easy to throw some "test code" in after assigning 'levelnum = 2;'. If the assignment is inside of a 'block', or function, make sure your test code is outside of it.

    Actually, alpha, Salem and Magos all have excellent suggestions. Check the "obvious" first before making this harder than it may be.

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  6. #6
    WhiteTiger
    Guest

    I'm not sure what I did..

    Not sure if I did anything at all but I re-compiled it and it worked fine. Anyways, thanks for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c++builder6 change form names problem
    By Leite33 in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2008, 08:20 AM
  2. how to change static char* and not lose mem ?
    By jabka in forum C Programming
    Replies: 15
    Last Post: 09-07-2007, 05:33 PM
  3. Change Value in an array
    By beginner999 in forum C Programming
    Replies: 3
    Last Post: 01-18-2003, 06:16 AM
  4. Replies: 2
    Last Post: 11-08-2002, 02:22 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM

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