Thread: Trouble Initializing Array

  1. #1
    Registered User
    Join Date
    Oct 2011
    Location
    ~Sacramento, CA
    Posts
    14

    Trouble Initializing Array

    I'm trying to initialize all 5 elements of an array to 0 within a function.


    Code:
    double Init_Costs(double Array, double ArraySize)
    {
           int Counter;
           
           for(Counter=0; Counter<ArraySize; Counter++);
           {
                        Array[Counter]=0
           }
           
    }
    Using Bloodshed. Why does it say 'subscripted value is neither array nor pointer'? Isn't Counter supposed to take the place of the value it is holding? Also, how can I make sure that the results from this function change the actual value of my array (located in a different function)?

    thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Array is a double, not a pointer to the first element of an array. Also, the array size should be an integer, not a double.
    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
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Then once you have figured that out, you can see if you can hunt up the standard library function that will do that for you.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Location
    ~Sacramento, CA
    Posts
    14
    Array is a double, not a pointer to the first element of an array. Also, the array size should be an integer, not a double.
    I know that- but how do I tell it that I want to look into the same array element as times it has looped?

    Then once you have figured that out, you can see if you can hunt up the standard library function that will do that for you.
    lol

    Where would I start searching for it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem initializing a double array for large array
    By gkkmath in forum C Programming
    Replies: 4
    Last Post: 08-25-2010, 08:26 PM
  2. trouble initializing a dynamic array of pointers to NULL
    By supernater in forum C++ Programming
    Replies: 8
    Last Post: 09-13-2009, 04:47 PM
  3. Array initializing
    By RoshanX in forum C++ Programming
    Replies: 2
    Last Post: 03-23-2006, 02:40 PM
  4. trouble initializing constructor
    By dantestwin in forum C++ Programming
    Replies: 11
    Last Post: 07-06-2004, 01:31 AM
  5. help on initializing array
    By neversell in forum C Programming
    Replies: 6
    Last Post: 06-30-2002, 05:07 AM