Hello kerem59,
I did find "<process.h>", but this is a C header file and you do not use anything from this header file in your code. When I put a comment on that line it compiled with no problem with VS2017. Also I am not sure where this header file is located, but it is not in with the standard C++ header files. This usually it is best not to unless you have to.
Your variables
int k, num, m;
. "k" and "m" may mean something to you, but they need a better name like "menuChoice" for "m". I have not figured out what "k" is for yet, but it should have a name that describes what it is used for.
Next question is do you have to create your own list or is this program to use "std::list" from the "list" header file?
Some small things:
You do not need a "cout" for every line of your menu. Using the "\n"s as you did is good.
You can change your menu to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
cout <<
"\n MENU\n"
" ---------------------------------\n"
" 1 - Add the first element\n"
" 2 - Add the element before k\n"
" 3 - Add the element after k\n"
" 4 - Add the last element\n"
" 5 - Del the first element\n"
" 6 - Del the element with value k\n"
" 7 - Del the last element\n"
" 8 - Search element\n"
" 9 - Show the list\n"
" 10 - Exit\n" // <--- Changed. Added the "\n".
"\n Your choice: "; // <--- Changed. Removed a "\n". Added a space after the (:).
cin >> menuChoice;
|
The really neat part about this is that each quoted string is considered just 1 big string.
In the switch you do not need the {} after "case 1:" You only need the {}s if you define a variable in a case. Then this variable is local to the {}s and is lost when you reach the closing brace.
I would suggest using:
1 2 3 4 5 6 7 8
|
switch (menuChoice)
{
case (1):
add_b(num);
list();
break;
|
This layout until you get use to it. Leave the 1 liners for later when you are use to it. It really helps in the beginning.
Since you do not check what you enter for "menuChoice" the switch could use a "default" case to catch any number out of range of your choices.
To do your "cin" for "menuChoice" properly you should be checking for any non numeric input that would cause "cin" to fail. Because if it does fail it will be unusable the rest of the program. I will have to work up the code for this and show you in a bit.
Andy