In this exercise there are 4 sales people and 5 products. I'm supposed to figure out how much of each product each sales person sold in a month. initSales randomly generates the sales into transaction[][][] and succeeds in doing so. The problem I'm having is with totalSales which is supposed to total all the sales for a month for every product a person sold in a month. Whenever I try to compile the program I get,
6.22.c: In function `main':
6.22.c:23: warning: passing arg 1 of `totalSales' from incompatible pointer type
6.22.c:23: warning: passing arg 2 of `totalSales' from incompatible pointer type
What am I doing wrong?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define PERSON 5
#define PRODUCT 6
#define DAY 31
void initSales( int [][][] );
void totalSales( int [][], int [][][] );
int main()
{
int transaction[ PERSON ][ PRODUCT ][ DAY ] = { 0 };
int sales[ PERSON ][ PRODUCT ] = { 0 };
srand( time(NULL) );
initSales( transaction );
totalSales( transaction, sales );
return 0;
}
void initSales(int var[][ PRODUCT ][ DAY ])
{
int i, j, k;
for (i = 1; i <= PERSON - 1; ++i) {
for (j = 1; j <= PRODUCT - 1; ++j) {
for (k = 1; k <= DAY - 1; ++k) {
var[i][j][k] = rand() % 1000;
/* test statement below */
// printf("person: %d\nproduct: %d\n day: %d\nsold: %d\n\n", i, j, k, var[i][j][k]);
}
}
}
return;
}
void totalSales( int sumofSales[][ PRODUCT ], int transactionsMade[][ PRODUCT ][ DAY ] )
{
int a, b, c;
for (a = 1; a <= PERSON - 1; ++a) {
for (b = 1; b <= PRODUCT - 1; ++b) {
for (c = 1; c <= DAY - 1; ++c) {
sumofSales[ a ][ b ] += transactionsMade[ a ][ b ][ c ];
/* test statement below */
printf("person: %d\nproduct: %d\nsold: %d\n\n", a, b, sumofSales[ a ][ b ]);
}
}
}
return;
}