Hi there! Was hoping for a little help with C. I'm simply trying to return managerTotal, hourlyTotal, commissionTotal and pieceworkerTotal to the totalOutput function. I need to keep the same function structure (you'll notice the functions that hold the floats are called through choiceInput which is called from choosePayroll etc etc). Any ideas?
Here is the code:
#include<stdio.h>
#include<conio.h>
void totalOutput(float *managerTotal, float *hourlyTotal, float
*commissionTotal, float *pieceworkerTotal) {
printf("Manager total is: $%.2f", managerTotal);
printf("Hourly total is: $%.2f", hourlyTotal);
printf("Commission total is: $%.2f", commissionTotal);
printf("Pieceworker total is: $%.2f", pieceworkerTotal);
}
float managerIntro() {
float managerTotal = 1; // trying to pass this through to the totaloutput function
return managerTotal;
}
float hourlyIntro() {
float hourlyTotal = 2; // trying to pass this through to the totaloutput function
return hourlyTotal;
}
float commissionIntro() { // trying to pass this through to the totaloutput function
float commissionTotal = 3;
return commissionTotal;
}
float pieceworkerIntro() { // trying to pass this through to the totaloutput function
float pieceworkerTotal = 4;
return pieceworkerTotal;
}
float choiceInput() {
float a = managerIntro();
float b = hourlyIntro();
float c = commissionIntro();
float d = pieceworkerIntro();
totalOutput(float a,float b,float c,float d);
}
void choosePayroll(){
choiceInput();
}
int main() {
choosePayroll();
getchar();
return 0;
}
(float *managerTotal, float *hourlyTotal, float
*commissionTotal, float *pieceworkerTotal)
Are pointers , so:
totalOutput(&a,&b,&c,&d);
or remove * from totalOutput function declaration
>>298299
That absolutely worked on the stripped down code, thank you for that. Any ideas why it's not working here?
Long code:
https://pastebin.com/iKCDLDd1
>>298302
>https://pastebin.com/iKCDLDd1
Add float choiceInput(); below the includes,
The function was not defined in your case because it was below the function that used it so the compiler did not find its definition in the context of the code that was currently processed
Still not working for me :/ Anyone able to get it working how it should? 5am and about to cry over this lmao.
>>298310
You also call totalResult(); which does not exist
I assume that you meant to call totalResult();
Anyway im too lazy to put that in to a compiler just pastebin the compiler messages if this still does not work.
>>298314
*meant to call totalOutput()
No wonder you fucked up , even i confused it.
https://pastebin.com/dSFG9ZsF
Believe I fixed everything you guys mentioned and still nothing.