Is there any function in C on Linux that permit to wait an user input without displaying on terminal what he is typing ? (like when you enter your password on terminal on Linux)
I found getch() but it's not working on Linux ... :(
I found this but it's too complicated ... :
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
int main(void)
{
char buffer[100];
struct termios infos;
int size;
if (tcgetattr(STDIN_FILENO, &infos) == -1)
{
fprintf(stderr, "Erreur tcgetattr.\n");
return (EXIT_FAILURE);
}
infos.c_lflag &= ~ECHO;
if (tcsetattr(STDIN_FILENO, TCSANOW, &infos) == -1)
{
fprintf(stderr, "Erreur tcsetattr.\n");
return (EXIT_FAILURE);
}
if ((size = read(STDIN_FILENO, buffer, sizeof(char) * 100)) == -1)
{
fprintf(stderr, "Erreur durant la lecture.\n");
return (EXIT_FAILURE);
}
buffer[size - 1] = '\0';
printf("le buffer contient [%s]\n", buffer);
return (EXIT_SUCCESS);
}