Hello guys again.. Well I could cut the part with colors clear screen and cursor hide, actually doesn't matter I just use that indead for fancy things like
said, but that is not my goal, I did use those before I realize I want to do other things like my OP question. Of course I could get rid of:
THIS:
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
|
and put this in the code for visibility:
1 2 3 4 5 6 7 8 9 10 11
|
char *selector[] =
{
"\t -> New user",
"\t New user",
"\t -> Old user",
"\t Old user",
"\t-> Delete user",
"\t Delete user",
"\t -> Exit",
"\t Exit"
};
|
or get rid of the hideCursor() function either way this really does not matter more than the other.
Non of these actually make the code look worst, they don't provide tones of lines and make it unreadable. Not even system("cls") function which provide
1 line of code and if not clear the screen you can take my code test it and see how behaves without it. I like all of your comments, I really do, but do not take it personally
Genado the things you just said with CLI and TUI does not interest anyone, and my question wasn't refer to that in particular thing. Other than that let's say I did not provide that at all, how would you see a solution for my issue, of course I don't expect anyone solve it for me I just want some ideas.
But what I was trying to say, is how to store into an array my list from the text, that later I'll use it as a menu, and behave like the example code I gave you at the begining. I believe everyone has played lots of games and I just want this to turn like a menu in case someone needs to choose from a list of players and just hit ENTER to choose that player , which was my question from the start.
As I have think about first to store double name in another file that later I'll have to store that into an array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
void MenuSelectExistingUser(unsigned int select)
{
struct USER name; // a structure that I have not provide first.
FILE *file = fopen("newUser.txt", "r"); // read from the file that contain the users
FILE *file2 = fopen("oldUser.txt", "a+"); // store in double name that are in the first file
int k = 0; // I can use this to count the number of lines (k * 2) later when need
printf("\n\t\t\t\tNew type menu\n");
printf("\t\t\t\t-------------\n\n\n");
printf("\tSelect user:\n\n\n\n\n");
for(k = 0; fgets(name.user, 255, file) != NULL; k++)
{
fprintf(file2, "%s", name.user);
fprintf(file2, "%s", name.user);
}
fclose(file);
rewind(file2);
...
..
.
}
|
EDIT
I said double lines before because the array has to look like this:
1 2 3 4 5 6 7 8 9 10 11
|
char *selector[] =
{
"\t New user",
"\t New user",
"\t Old user",
"\t Old user",
"\tDelete user",
"\tDelete user",
"\t Exit",
"\t Exit"
};
|