Trouble Initializing Array

This is a discussion on Trouble Initializing Array within the C Programming forums, part of the General Programming Boards category; I'm trying to initialize all 5 elements of an array to 0 within a function. Code: double Init_Costs(double Array, double ...

  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
    21,781
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21