View Poll Results: What is the rating you gives to this question

Voters
1. You may not vote on this poll
  • Foolish

    0 0%
  • extremely foolish

    1 100.00%
  • good

    0 0%
  • awesom

    0 0%

Thread: Value of a variable when it is not reserved

  1. #1
    Registered User linuxlover's Avatar
    Join Date
    Nov 2010
    Location
    INDIA
    Posts
    52

    Value of a variable when it is not reserved

    What is the value of a variable when it is delared
    ie.
    int x ;
    This declaration allocates 2 bytes of memory (not in linux) and we can refer to that memory as a.will it erases the data at that location and initialises a to 0..also what happens when an uninitialised variable is passed to a function..

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    If x has static storage duration (it is not declared static, but it could be a global variable), then it will be zero initialised. If x has automatic storage duration (e.g., it is a local variable), then its initial value is indetermine (or "garbage").
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User linuxlover's Avatar
    Join Date
    Nov 2010
    Location
    INDIA
    Posts
    52
    thanks for that...I forgot basic things like storage classes...thanks a lot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 02-14-2010, 04:14 PM
  2. What are all the reserved names in C?
    By dwks in forum C Programming
    Replies: 7
    Last Post: 09-14-2005, 04:57 PM
  3. Reserved namespace and illegal names
    By ^xor in forum C Programming
    Replies: 8
    Last Post: 08-11-2005, 08:38 PM
  4. Reserved characters in an array?
    By xolstis in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-02-2004, 04:23 AM
  5. size of the memory reserved for a pointer
    By cris_orpi in forum C Programming
    Replies: 13
    Last Post: 03-05-2003, 11:42 AM

Tags for this Thread