Hiding Input in C
Abaze
-
ajslenegus -
ajslenegus -
Hello,
I would like to know if there is a way to hide input using the C language.
Actually, I am developing an application (... rock, paper, scissors... lol it’s for a professional project :( )
And in the Player 1 vs Player 2 part, it would be great if each player could enter their choice without it being visible on the screen... otherwise, hello cheating lol (that's -5 on the BTS, that's why I’m freaking out lol)
That's all, if you have a little tip I’m ready to receive it
Thanks in advance @+++
I would like to know if there is a way to hide input using the C language.
Actually, I am developing an application (... rock, paper, scissors... lol it’s for a professional project :( )
And in the Player 1 vs Player 2 part, it would be great if each player could enter their choice without it being visible on the screen... otherwise, hello cheating lol (that's -5 on the BTS, that's why I’m freaking out lol)
That's all, if you have a little tip I’m ready to receive it
Thanks in advance @+++
14 réponses
Hello,
Please, who can help me? Tomorrow morning I have a graded lab in programming: write a function SAISIR_PASSWD that allows entering a password with **** displayed on the screen. The password will be encrypted before being stored.
Please, who can help me? Tomorrow morning I have a graded lab in programming: write a function SAISIR_PASSWD that allows entering a password with **** displayed on the screen. The password will be encrypted before being stored.
Hi =)
You could perhaps relate the key choice to the press of a button, and detect it without displaying it using the function (well, if you’re using VC++) PreTranslateMessage(). And place the keys side by side to minimize the risk of cheating (ideally, it would be best to make the keys configurable).
++
You could perhaps relate the key choice to the press of a button, and detect it without displaying it using the function (well, if you’re using VC++) PreTranslateMessage(). And place the keys side by side to minimize the risk of cheating (ideally, it would be best to make the keys configurable).
++
Yes, that's right, I use VC++.....but I'm not very familiar with the configuration...but I will check how to use the PreTranslateMessage() function.
Thank you for your help ;) ++
Thank you for your help ;) ++
...if it can help to better see where I'm coming from:
You will see below the player's menu...and I'm trying to find a way to hide their input
int submenu()
{
char y;
printf("--Player 1--\n");
printf("___________________________________\n");
printf("--MAKE YOUR CHOICE--\n\n");
printf("[1] Rock\n");
printf("[2] Paper\n");
printf("[3] Scissors\n");
printf("___________________________________\n");
puts("What is your choice:\n");
scanf("%c",&y);
while(y<49 || y>51)
{ printf("Incorrect choice!\n");
printf("Please re-enter your choice: ");
scanf(" %c",&y);
system("cls");
}
return y;
}
I'm looking at the keyboard key detection functions....:O it's not that straightforward (lol I'm a bit lost, I admit)
Well, if you know how to do it, even just a little help would be appreciated lol
thanks in advance
You will see below the player's menu...and I'm trying to find a way to hide their input
int submenu()
{
char y;
printf("--Player 1--\n");
printf("___________________________________\n");
printf("--MAKE YOUR CHOICE--\n\n");
printf("[1] Rock\n");
printf("[2] Paper\n");
printf("[3] Scissors\n");
printf("___________________________________\n");
puts("What is your choice:\n");
scanf("%c",&y);
while(y<49 || y>51)
{ printf("Incorrect choice!\n");
printf("Please re-enter your choice: ");
scanf(" %c",&y);
system("cls");
}
return y;
}
I'm looking at the keyboard key detection functions....:O it's not that straightforward (lol I'm a bit lost, I admit)
Well, if you know how to do it, even just a little help would be appreciated lol
thanks in advance
Yeah, thanks guys,
but I gave up, I preferred to develop my program under Windows with <conio.h> (which solves all the problems at once BAM!!!! lol) because it goes way too far under Linux, I tried <curses.h> and <ncurses.h> and it’s clear that it’s SUPER ANNOYING!!
Well, thanks again for your answers, I still learned some things anyway lol
Alright, good luck ;) ++</ncurses.h></curses.h></conio.h>
but I gave up, I preferred to develop my program under Windows with <conio.h> (which solves all the problems at once BAM!!!! lol) because it goes way too far under Linux, I tried <curses.h> and <ncurses.h> and it’s clear that it’s SUPER ANNOYING!!
Well, thanks again for your answers, I still learned some things anyway lol
Alright, good luck ;) ++</ncurses.h></curses.h></conio.h>
I'm sorry, I didn't realize that you were playing your game in the console; I thought you had created a dialog box.
Also, I just checked on MSDN and the PreTranslateMessage() function belongs to the CWnd class, so it's C++. I'll see if there's another way.
++
Also, I just checked on MSDN and the PreTranslateMessage() function belongs to the CWnd class, so it's C++. I'll see if there's another way.
++
lol Yeah, my game is on the console (I didn't overthink it lol ...:( )
Thanks for your help Luffy ;)
...now I just have the part "hide the player input" left and my project will be almost done! I hope lol
+++
Thanks for your help Luffy ;)
...now I just have the part "hide the player input" left and my project will be almost done! I hope lol
+++
Hi,
If you don't necessarily need to validate the input with "Enter", you can try using the getch function found in the conio.h header.
Not knowing the Windows environment well, I'm not sure about the header, so check that ;-)
See you soon
--
Freedom is not given; it is taken...
If you don't necessarily need to validate the input with "Enter", you can try using the getch function found in the conio.h header.
Not knowing the Windows environment well, I'm not sure about the header, so check that ;-)
See you soon
--
Freedom is not given; it is taken...
I don't think it's possible to hide the writing on the console, as that's not part of your program but rather the console's - if you know what I mean. Anyway, if you find a way, let us know.
thanks
++
--
~ click @ left, click, click @ right, click, click
and there's no bug, sir! ~
thanks
++
--
~ click @ left, click, click @ right, click, click
and there's no bug, sir! ~
Yeah, thanks guys, with getch() it works fine!
LOL but I'm so disgusted.....
I made the application at home on Windows XP with Visual C+++.....
But at school I have to work on Linux Debian...
LOL and as if by chance the library <conio.h> (which contains the famous getch() function) doesn't exist under Linux (LOL I'm seriously going crazy)... I searched on the internet, and it said that the equivalent of <conio.h> under Linux is <ncurses.h>... I tried it but well :( the getch() function is still not recognized
LOL it seems like this is never going to end!! I'm continuing my research to see more in detail about <ncurses.h>
Okay, I'm getting back to it, and thanks again for your suggestions seriously, how much that helps speed things up ;)
A++++
LOL but I'm so disgusted.....
I made the application at home on Windows XP with Visual C+++.....
But at school I have to work on Linux Debian...
LOL and as if by chance the library <conio.h> (which contains the famous getch() function) doesn't exist under Linux (LOL I'm seriously going crazy)... I searched on the internet, and it said that the equivalent of <conio.h> under Linux is <ncurses.h>... I tried it but well :( the getch() function is still not recognized
LOL it seems like this is never going to end!! I'm continuing my research to see more in detail about <ncurses.h>
Okay, I'm getting back to it, and thanks again for your suggestions seriously, how much that helps speed things up ;)
A++++
Hi,
You will find a tutorial on ncurses here: http://ariffart.club.fr/sommaire01.html#planpgrc
See you++
--
Freedom is not given, it is taken...
You will find a tutorial on ncurses here: http://ariffart.club.fr/sommaire01.html#planpgrc
See you++
--
Freedom is not given, it is taken...
Hello, under Linux/Unix it is possible to hide what the user types on the keyboard with the POSIX API. It's not easy though. The principle is that a terminal receives the data from the keyboard, but they are stored in a queue. If the ECHO option is enabled, then everything you type is displayed. Check out termios, you have its manpage here http://www.opengroup.org/onlinepubs/009695399/basedefs/termios.h.html
--
tafiscobar ""lou waye def bopame"
nullity does not exist, ignorance does, oh I suppose!!!
--
tafiscobar ""lou waye def bopame"
nullity does not exist, ignorance does, oh I suppose!!!