This is a part of the problem in my homework. I have :
int alpha[20]; int beta[20]; int inStock[10][4]; I need to write a function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the last five rows of inStock.

my program is here, but I got error message.

void copyAlphaBeta(const int alpha, const int beta,
                         int& i, int& j, int inStock[][4])
{
     int row, col;
     i = 0;
     j = 0;
     for(row = 0; row < 5; row++)
        for(col = 0; col < 4; col++)         
        {
           inStock[row][col] = alpha[i]; // here is the error      
           i++;
        } 
     
     for(row = 5; row < 10; row++)
         for(col = 0; col < 4; col++)
         {
             inStock[row][col] = beta[j];
             j++;
         }
 }

You declared alpha and beta as int instead of an array in the function definition.

You declared alpha and beta as int instead of an array in the function definition.

Oh right. Thank you boblied. : ) I've changed it and the error message is gone now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.