I want to pass an integer to a function, have the function edit it and then pass back the integer to the main function. I am working on this but it isn’t working.
Here is my code:
int update_SEG_values(int DIGIT_1, int DIGIT_2) {
// How many tens in the "TEMP_COUNT".
DIGIT_2 = ((TEMP_COUNT) / 10);
// How much is left for us to display.
TEMP_COUNT = TEMP_COUNT - ((DIGIT_2) * 10);
// How many ones.
DIGIT_1 = ((TEMP_COUNT) / 1);
return(DIGIT_1, DIGIT_2);
}
What am I doing wrong here?
You can only return one value in C
when you give :
due to the comma operator
DIGIT_2will be returned. For more info refer http://en.wikipedia.org/wiki/Comma_operatorYou can get your job done by using pointers or structures (both digits will be part of same structure and you return the same)