# Need help with - cannot convert parameter 1 from 'int' to 'int []

• 05-22-2010
kv0nza
Need help with - cannot convert parameter 1 from 'int' to 'int []
Hey,
Im new to programming (less than 3 months into a course) and we have a assignment (no im not asking you guys to do it for me :p) and iv written the below code but i keep getting this error

C2664: 'input' : cannot convert parameter 1 from 'int' to 'int []'

Sorry if i look like i have made a mess of the code most likely its all wrong but im new to coding and im finding it hard to wrap my hear around.

Code:

```#include <iostream> #include <iomanip> using namespace std; int input (int qtyStock[], int stockPrice[], int k) {         cin >> qtyStock[6];         cin >> stockPrice[6];        } void heading () {           cout << "-------------------------------------------------------------------------" << endl;           cout << "Stock Item" << setw(15) << "Quantity" << setw(10) << "Unit Price" << setw(15) << "Total Value" << endl; } int outputGross(int &gross) { } int computation (int qtyStock[], int stockPrice[], int stockValue[]) { } int output (int qtyStock[], int stockPrice[], int stockValue[], int gross, int m) { } int main() {         int qtyStock[6] = {0,0,0,0,0,0};         int stockPrice[6] = {0,0,0,0,0,0};         int stockValue[6] = {0,0,0,0,0,0};         int k;         int gross;         for (int k = 0; k < 6; k++)                 {                         input(qtyStock[k], stockPrice[k], k);                         gross += computation(qtyStock[k], stockPrice[k], stockValue[k]);                 }         heading();         for (int m = 0; m < 6; m++)                 {                         output(qtyStock[m], stockPrice[m], stockValue[m], gross, m);                 }         outputGross(gross);         system("pause");     return 0; }```
• 05-22-2010
jeffcobb
Not sure about your specific error since you didn't really say what line it was on but where you are doing this:
Code:

```        cin >> qtyStock[6];         cin >> stockPrice[6];```
What is it you are trying to do exactly? Because the thing is, these integer arrays are 6 elements in size and are zero based so only 0-5 are valid elements. qtyStock[6] will overwrite some bit of your memory, probably your stack with less than savory results....so you are allocating room for 6 integers and using cin to read....what? 1 element? and which element of the array is it meant for?
• 05-22-2010
kv0nza
Quote:

Originally Posted by jeffcobb
Not sure about your specific error since you didn't really say what line it was on but where you are doing this:
Code:

```        cin >> qtyStock[6];         cin >> stockPrice[6];```
What is it you are trying to do exactly? Because the thing is, these integer arrays are 6 elements in size and are zero based so only 0-5 are valid elements. qtyStock[6] will overwrite some bit of your memory, probably your stack with less than savory results....so you are allocating room for 6 integers and using cin to read....what? 1 element? and which element of the array is it meant for?

Im trying to make a program that asks for 6 elements in the qtyStock array and then do the same for stockPrice array then feed that back into the for loop.
• 05-22-2010
grumpy
The complaint from the compiler would be occurring in main(), in the first loop.

The line
Code:

`input(qtyStock[k], stockPrice[k], k);`
is trying to pass integral values where an array of integers (or, depending on context, a pointer) is expected.

The use of index 6 inside the function is also a problem as others have mentioned. However that will not cause a compiler error. It may (depending on how input() is called) cause undefined behaviour, often visible in the form of a program crash.