• [^] # Re: pas la bonne méthode

    Posté par . En réponse au message Masquer stdout puis réafficher.. Évalué à 3.

    Ceci dit, je dis qu'il ne faut pas s'occuper de stdout et je le fait ...
    La fonction passwd doit utiliser stdin, et donc:

    char* passwd ()
    {
    int fail;
    char *p;
    struct termios termio;

    fail = tcgetattr (0, &termio);
    if (fail) {
    perror ("tcgetattr");
    return 0;
    }

    termio.c_lflag &= ~ECHO;
    fail = tcsetattr (0, TCSANOW, &termio);
    if (fail) {
    perror ("tcsetattr");
    return 0;
    }

    p = fgets (password, -1+sizeof password, stdin);
    termio.c_lflag |= ECHO;
    tcsetattr (0, TCSANOW, &termio);

    return p;
    }