Pointers and Functions

Because this is a school assignment i left out the rest of the code.
I don't want to accused of copying this code...which would still be mine.

Anyways i left the function prototype, function header, and function call.
I'm getting the issue with the function call.
I have to have dynamically allocated arrays. My function call needs to send those arrays to the function so that they can be filled with information, but codeblocks wont compile and i don't know why.

----------------------------------------------------------------------------

void getData(int *idPtr, int *ratePtr, int numEmp); // Function prototype


int main()
{
int* idPtr = nullptr; // Pointer
idPtr = new int[numEmp]; // dynamically created array
int* ratePtr = nullptr; // Pointer
ratePtr = new int[numEmp];// dynamically created array


// The issue is here. "error. invalid conversion from 'int' to 'int*'
getData(*idPtr, *ratePtr, numEmp);

return 0;
}

void getData(int *idPtr, int *ratePtr, int numEmp)// function header
{
//function
}
The arguments of getData() are type pointer to int, pointer to int and int respectively (respt) while in main() you're supplying dereferenced pointer to int, dereferenced pointer to int and int respt to getData(). Remove the * from the first 2 variables
Topic archived. No new replies allowed.