[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

C Programming

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 9
Thread images: 1

File: unnamed.png (19KB, 300x300px) Image search: [Google]
unnamed.png
19KB, 300x300px
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.
>>
>>298302
>>298310
Well for one thing, your switch cases are falling through because you have no break statements on the ends of any of them.
>>
https://pastebin.com/dSFG9ZsF

Believe I fixed everything you guys mentioned and still nothing.
Thread posts: 9
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.