Thread: Reinitializing a variable

  1. #1

    Reinitializing a variable

    I am very new to the C programming language and I am working on a project that involves reinitializing a varialbe(s).

    Could someone clue me in how to do this, I am confused

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    You can say, for example:


    anywhere in the program - you just have to declare them at the beginning; the values can (usually) be changed anywhere.

  3. #3
    Registered User
    Join Date
    Jan 2002
    If you initialize like so:

    int i = 5;

    Then, anywhere that the integer i is in scope, you can change its value:

    i = 2;

    But if you declare the integer as constant:

    const int i = 5;

    The compiler won't let you put another value into this variable.

    i = 8 // compiler will bomb here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  2. static class variable vs. global variable
    By nadamson6 in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2005, 03:31 PM
  3. Replies: 2
    Last Post: 04-12-2004, 01:37 AM
  4. write Variable and open Variable and get Information
    By cyberbjorn in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 01:30 AM
  5. Variable question I can't find answer to
    By joelmon in forum C++ Programming
    Replies: 3
    Last Post: 02-12-2002, 04:11 AM