The switch menu does not call the function.
compiler says undefined function!! Why???
Is the description on top of the functions right for doxygen?? makes sense??
Thanks for looking into it!!
have a nice Easter!!
/**************
Author: Bla bla
Date: 17/04/2014
Description: Menu program w/ 4 option, for lab 7, question 2.
A-Display name. B-Display tuto time. Q-Quit
C- Read in a positive number between 1-50 and
display all numbers from 0 up to the number entered
**************/
#include <stdio.h>
#include <ctype.h>
/*************
Description: display_menu (only displays menu)
Parameters in: N/A
Parameters out: N/A
Return: N/A
*************/
void display_menu (void)
{
printf("You have 4 choices.");
printf("Enter a for my name.");
printf("Enter b for my tutorial date.");
printf("Enter c to read a positive number & display all numbers.");
printf("Enter q to quit.\n");
return;
}
/*************
Description: get_choice
Parameters in: N/A
Parameters out: response
Return: Users choice.
*************/
char get_choice (void)
{
char response;
scanf("%c%*c",&response);
response = tolower(response);
return(response);
}
/*************
Description: menu
Parameters in: choice
Parameters out: N/A
Return: Doesnt return, process the user choice.
*************/
void performe_action (char choice)
{
switch (choice)
{
case'a':
print_name();
break;
case'b':
print_lab();
break;
case'c':
get_calculate_number();
default:
printf("Invalid input\n");
}
return;
}
/*************
Description: Print function - name
Parameters in: N/A
Parameters out: N/A
Return: N/A
*************/
void print_name (void)
{
printf ("My name is bla bla");
return;
}
/*************
Description: Print function - lab time
Parameters in: N/A
Parameters out: N/A
Return: N/A
*************/
void print_lab (void)
{
printf ("My lab is on bla bla");
return;
}
/*************
Description: get and calculate number
Parameters in: get number from function get_number
Parameters out: print the result from print_number
Return: N/A
*************/
void get_calculate_number (void)
{
int number;
number = get_number();
print_number(number);
return;
}
/*************
Description: get a number
Parameters in: N/A
Parameters out: number choice
Return: N/A
*************/
int get_number (void)
{
int number;
printf ("What is your number");
scanf ("%d%*c", &number);
return(number);
}
/*************
Description: get a number
Parameters in: N/A
Parameters out: number choice
Return: N/A
*************/
void print_number(int number)
{
int x;
for(x=1; x<=number; x++)
{
printf ("The result is %d", x);
}
return;
}
int main()
{
char choice;
do
display_menu();
choice = get_choice();
performe_action(choice);
while(choice != 'q')
return(0);
}
A tip from me would be to always prototype your functions above(outside) of main and then define them below(outside) of main. This will clean up your code and save you a hassle.