Write a C program that show the following menu items and gets the user input that is one of letters given in brackets. Then, it calls the corresponding user-defined function. For example, if the user hits V key from the keyboard, program calls the fViewMenu() function. It is expected that you should write these functions as well :).
[F]ile -> fFileMenu()
[E]dit -> fEditMenu()
[V]iew -> fViewMenu()
[O]ptions -> fOptionsMenu()
[H]elp -> fHelpMenu()
im at university. i dont know much things about programming. its 3rd lesson and he asked me this question. i asked if you help. Thx.
Don't post homework questions
Programmers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.
Okay, based on your (apparent) lack of C++ knowledge (or the difference between C and C++), I would recommend that you spend the next four to five hours reading everything in http://www.cplusplus.com/doc/tutorial/
I told you what you need to do with your level of understanding, and you decided not to take my advice. So I'm answering your specific questions with specific answers.
What I'm not doing, and won't do, is what you haven't specifically asked me to do, but apparently is what you're seeking: write your program for you.
#include <stdio.h>
#include <conio.h>
main(void)
{
char folder, c;
printf("Select folders and write its first character. Folders: File, Edit, View, Options, Help");
scanf("%d", &folder);
switch (folder) {
case 'f':
case 'F':printf("You are in file folder\n");break;
}
c=getch();
return 0;
}
(You r right ciphermagi sry. i have to be quickly . i couldnt go last lesson. Im tryng to do it since 3hour. its really hard to learn myself. thx for helping )
i wrote it. and it worked. but when i pressed F and enter it closes. whats wrong ?
int main(void)
{
char myAnswer, c; // Indent
printf("[F]ile [E]dit [V]iew [O]ptions [H]elp \n"); // Indent
scanf("%c", &myAnswer); // New line after every command
switch (myAnswer) { // Indent
case'f': // Indent
case'F': // Indent
fFileMenu(); // New line after every command
break; // New line after every command
case'e': // Indent
case'E': // Indent
fEditMenu(); // New line after every command
break; // New line after every command
case'v': // Indent
case'V': // Indent
fViewMenu(); // New line after every command
break; // New line after every command
case'o': // Indent
case'O': // Indent
fOptionsMenu(); // New line after every command
break; // New line after every command
case'h': // Indent
case'H': // Indent
fHelpMenu(); // New line after every command
break; // New line after every command
default: // Indent
printf("I think your answer is Maybe ?\n"); // New line after every command
} // Indent
c = getch(); // Indent
return 0; // Indent
}