LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   A couple of non-functioning functions. (https://www.linuxquestions.org/questions/programming-9/a-couple-of-non-functioning-functions-126810/)

Tarts 12-17-2003 09:51 PM

A couple of non-functioning functions.
 
I cant seem to get these functions to work on my system, I would be much obliged if someone could compile/run them.

Code:

#include <termios.h>
#include <unistd.h>
#include <stdio.h>
struct termios save_attr;
void set_terminal(void)
{
        struct termios set_attr;
        set_attr.c_lflag &= ~(ICANON|ECHO);
        tcgetattr(0, &save_attr);
        tcsetattr(0, TCSANOW, &set_attr);
}


void reset_terminal(void)
{
        tcsetattr(0, TCSANOW, &save_attr);
}

int main()
{
        char buf[100];
        printf("Enter your name...\n");
        set_terminal();
        fgets(buf, sizeof(buf), stdin);
        reset_terminal();
        printf("Your name is %s\n", buf);
        return 0;
}

Its official, what worked in Slackware 8.1 (above), does not work in 9.1. I would be interested to know why...:scratch:


All times are GMT -5. The time now is 06:25 AM.