Hi, could somebody give me an idea?
I have a problem in this little program I'm trying to put together for college.
The question I have is in case 2 i'm trying call a function and compiler's error is too few arguments. What should I do?
#include <stdio.h>
#include <stdlib.h>
#define ERROR "Please input data first\n\n"
int menu(void);
/* Purpose: display the menu with options and return valid option*/
int input_number_of_readings(void);
/* Purpose: Input number of readings*/
int input_reading_number(void);
/* Purpose: Input number of reading*/
int input_times(int number_of_readings, float times[], float readings[]);
/* Purpose: Input times for each reading*/
void input_readings(int number_of_readings, float reading, float readings[]);
void display_results(int number_of_readings, float times[], float readings[]);
/* Purpose: display the results of each reading*/
main()
{
float *times=NULL;
float *readings=NULL;
int number_of_readings=0, reading_number;
int number_of_bytes;
int choice;
float fastest_morning, slowest_morning,
fastest_afternoon, slowest_afternoon,
fastest_evening, slowest_evening,reading;
do
{
choice=menu();
switch (choice)
case 0:
printf("End of program\n\n");
break;
case 1:
number_of_readings=get_number_of_readings();
reading_number=input_reading_number();
if (times!=NULL)
free(times);
if (readings!=NULL)
free(readings);
number_of_bytes=number_of_readings*sizeof(float);
readings=(float*) malloc(number_of_bytes);
number_of_bytes=number_of_readings*sizeof(float);
times=(float*) malloc(number_of_bytes);
if (readings==NULL || times==NULL)
{
printf("Memory allocation error\n");
exit (1);
}
case 2:
input_readings(int number_of_readings, float reading, float readings[]);
input_times(int number_of_readings, float times[], float readings[]);
}
int menu()
{
int menu_choice;
int max_choice=4;
printf("\n\n********************Menu********************\n");
printf("1. Input the number of readings *\n");
printf("2. Input readings and times *\n");
printf("3. Display the wind speeds *\n");
printf("4. Display the fastest and the slowest *\n");
printf("5. Exit\n\n *\n\n");
printf("6. Choose option 0-%d:",max_choice);
do
{
scanf("%d",&menu_choice);
}
while (menu_choice<0 || menu_choice>max_choice);
return (menu_choice);
}
/*_____________________________________________*/
int input_number_of_readings()
{
int number_of_readings;
do
{
printf("Enter number of readings (3 minimum):");
scanf("%d",&number_of_readings);
}
while (number_of_readings<3);
return number_of_readings;
}
/*_____________________________________________*/
int input_reading_number()
{
int reading_number;
printf("Enter reading number:");
do
scanf("%d",&reading_number);
while (reading_number<1);
return (reading_number);
}
/*____________________________________________*/
int input_times(int number_of_readings, float times[], float readings[])
{
int i;
printf(" Enter recorded times in the format 24.00\n\n");
for (i=0;i<number_of_readings;i++)
printf("Time for reading number%f:",readings[i]);
scanf("%.2f",×[i]);
}
/*_____________________________________________*/
void input_readings(int number_of_readings, float reading, float readings[])
{
int i;
printf("Enter readings:");
for(i=0;i<number_of_readings;i++)
printf("Reading for number%f:",readings[i]);
scanf("%f",&readings[i]);
}
/*____________________________________________*/
void display_results(int number_of_readings, float times[], float readings[])
{
int i;
for(i=0;i<number_of_readings;i++)
{
printf("Reading number: %f",readings[i]);
if(readings[i]==0)
printf("No wind");
else
printf("%f",times[i]);
}
}




