error: expected primary-expression before ']' token
calcNumbers(myArr[], type);
^
No idea what that means. Main issue seems to be at 11 but i think i have more than that. Also how can improve code? Do i put pointers somewhere or something, should i structure it more somehow or would this be applicable in a job?
#include <iostream>
void calcNumbers(int arr[] ,int type);
int askNumbers();
int askType();
int main()
{
int type = askType();
int myArr = askNumbers();
calcNumbers(myArr[], type);
}
int askType()
{
int type_ = 0;
std::cout << "1 for addition. 2 For subtraction. 3 for multiplication. 4 for division." << std::endl;
std::cin >> type_;
return type_;
}
int askNumbers()
{
int arr[] = {};
std::cout << "Enter as many numbers you'd like. Type 0 to stop." << std::endl;
int i = 0;
do
{
std::cin >> arr[i];
i++;
}
while(arr[i] != 0);
return arr[];
}
void calcNumbers(int arr[] , int _type)
{
int arrSize = (int)( sizeof(arr));
int totalNumber = 0;
for(int i = 0; i < arrSize; i++)
{
if (_type == 1)
totalNumber += arr[i];
else if (_type == 2)
totalNumber -= arr[i];
else if (_type == 3)
totalNumber *= arr[i];
else if (_type == 4)
totalNumber /= arr[i];
}
std::cout << totalNumber << std::endl;
}
thanks in advance, i really cannot wrap my head around this wierd issue...