Thread: Two-dimensional bool array looses value when shared with another function

  1. #1
    Registered User
    Join Date
    Apr 2011
    Location
    London
    Posts
    1

    Two-dimensional bool array looses value when shared with another function

    Hello,

    In main() I declared the variable bool polExistence[MAX_POLS][TIME_MAX]. The individual elements acquire values while in main(), before the array is sent to the function CalcChipDensity() to be used it for another operation. The problem I am facing is that values that used to be true in main() are turned into false in CalcChipDensity() before I even manipulate the array in CalcChipDensity().

    The function prototype for CalcChipDensity is:
    void CalcChipDensity(bool polExistence[MAX_POLS][TIME_MAX]);
    CalcChipDensity() is called from main() with: CalcChipDensity(polExistence);

    Does anybody know why the content of bool array elements is lost when it is transferred to another function?

    Thank you!

    Andy

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Post the smallest and simplest compilable program that demonstrates the problem.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Returning a two-dimensional array in a function
    By neptunusmaris in forum C Programming
    Replies: 5
    Last Post: 07-02-2009, 07:44 AM
  2. How Do I Send a Two-Dimensional Char Array to a Function?
    By DonFord81 in forum C Programming
    Replies: 7
    Last Post: 02-26-2009, 03:01 AM
  3. Passing 2 dimensional array to a function
    By salvadoravi in forum C Programming
    Replies: 10
    Last Post: 01-16-2008, 12:38 AM
  4. ? passing multi dimensional array to function
    By rc7j in forum C++ Programming
    Replies: 1
    Last Post: 02-10-2002, 02:19 AM
  5. Replies: 4
    Last Post: 11-07-2001, 02:46 PM