Thread: levelnum = 1; wont change to levelnum = 2;

  1. #1

    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
    Groningen (NL)
    Can you show your code?

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    You don't do this, right?
       LevelNum = 1;
       ... //The rest of the code
       LevelNum = 2;

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

    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
    or perhaps levelnum is a const.

  5. #5
    Registered User
    Join Date
    Apr 2002
    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.

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

  6. #6

    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, 07:16 AM
  4. Replies: 2
    Last Post: 11-08-2002, 03:22 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM