Trouble defining a function that is passed an array, its size and an index

Hi,

In my code, I am defining the following function before the main void loop(). While compiling, it is giving me an error for the first line of below code saying
"a function-definition is not allowed here before '{' token"

Any idea, why its happening and how to fix it?

void process(int s[], int sizeofarray, int i) {
      g1=LOW ;                                              // turn off green LED for 1st bin pick
      w[i]=LOW ;                                            // turn off white LED for picked bin
      if (i==(n-1))                                             // if bin picked is last one
          {     g1=HIGH ;                                    // kit is complete as this is the last item
             count = count + 1 ;                           // increment count by 1
             w[0]=HIGH ;                                  // turn on white LED for first bin
           }    
      else                                                  // for bins other than last
        w[i+1]=HIGH ;                                     // turn on white LED for next bin
 }

And btw, I have defined another function by a different name in exactly the same manner above this which doesn't give an error while compiling.

FYI, this function is saying once an item is picked from a bin, turn off the LED for this bin and turn on LED for next bin. If its last bin, then increment count by one and turn on first bin's LED.

Entire code attached.

Regards.

sketch_apr03a.ino (2 Bytes)

Two_Bin_Trial_w_Function_Rev002.cpp (3.95 KB)

Wait is missing a }

Thank you DrAzzy.
It was the stupidest mistake that I could have done.

Thank you Delta_G for bringing a very useful tool to my attention.

Apart from the .ino file, I also created a .cpp file as recommended in other threads (and kept the .ino file blank). So which sketch to upload to Arduino Mega - .ino or .cpp?

At a later stage, I want to assign value to int n based on readings at a few digital pins. The arrays will be of size 'n'. Obviously 'n' can be read not before void setup(). Can the arrays be defined after void setup() outside void loop()?
If they are defined in setup or loop, will it have any impact while passing arrays & array_size & index_of_importance to the other functions?

Regards.

So which sketch to upload to Arduino Mega - .ino or .cpp?

If you upload in the IDE, all the tabs in your sketch are uploaded. You don't need to make that decision.

Thank you Nick.