| gets | Function* (tigcc.a)

stdio.h

char *gets (char *string);

Gets a string from the keyboard.

gets collects a string of characters terminated by a new line from the keyboard (by repeated calling to getchar) and puts it into string. The new line is replaced by a null character ('\0') in string. gets returns when it encounters a new line (i.e. when the ENTER key is pressed); everything up to the new line is copied into string. gets returns the string argument string (ANSI proposes returning of NULL in a case of error, but this never occurs on the TI). For editing, the backspace key is supported. Here is an example of usage:

    char buffer[50];
    int a, b;
    clrscr ();
    puts ("A = ");
    a = atoi (gets (buffer));
    puts ("B = ");
    b = atoi (gets (buffer));
    printf ("%d + %d = %d", a, b, a+b);

atoi is an ANSI C standard function from stdlib.h header file.
Important: gets does not check buffer bounds, so using getsn or a custom input routine is recommended instead.

Uses: fputchar, printf, EV_captureEvents, EV_defaultHandler, MoveTo, SaveScrState, ngetchx

See also: getsn, How can I get input from the keyboard?, textedit.h