how to return 2 values upon calling a function
Hi everyone. How would i return two values each time I call a function? I have this program here, that is extracting 2 values from a text file every time a function is called, but I only seem to be able to return one value each time the function is called. I need to return column1 and column2 each time readingFunction() is called and they should be stored in readingsArray[loop] and temperatureArray[loop]. is it possible to return two values upon calling a function?
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
float readingFunction(int loop);
int main(void)
{
int menu = 0;
int readingsArray[10];
float temperatureArray[10];
int loop=0;
do
{
printf("\n\n The sensor readings and their corresponding temperatures:\n\n");
for(loop=0; loop < 10; ++loop) // Gives the user a set of readings
{
temperatureArray[loop] = readingFunction(loop);
printf("\nreading number %i is %i which is %f degree's", loop, temperatureArray[loop]);
}
return 0;
float readingFunction(void)
{
FILE *fp;
int signalOutput;
int flag=0;
int column1;
float column2;
srand(time(NULL));
fp = fopen("LOOKUP.txt", "r");
signalOutput = (int)(rand()%15);
flag=0;
while( ! flag ){
fscanf(fp, "%i %f",&column1, &column2);
if ( signalOutput <= column1 )
{
flag = 1;
fclose(fp);
}
}
return column1;
}