[comp.sys.amiga] SAS/C - getchar

TEW105@psuvm.psu.edu (09/08/90)

I am new to C programing and just received my SAS/C 5.1.
Acording to the book I am using as a reference for C, the getchar() command
should wait for a character input, but when I use it, the program just skips
happily on by the command like it never existed.  Should I be using a loop
similar to what would be done with get a$ in basic?

BTW, my code looked something like this:
include# <stdio.h> (or whatever the standard one is>

main
{
  char showall;

  printf ("Show all output (y/n)? \n");
  showall=getchar();

  blah... blah.. blah..

}

Also, anysuggestions for using SAS/C on a 2 floppy, 1 meg, no HD system?
Thanks for all help!
        L8R,      ___  |                     |A     |IF IT FALLS ON YOUR
||_||  _          \\   |   ELECTRIC DREAMS!  | M    |HEAD, THEN YOU KNOW
||-|| |_| |\| |_| __\\ |_____________________|  I   |IT'S A ROCK.
DISCLAMIER: THESE ARE MY OPINIONS, NOT ANYONE|   G  |          -BINABIK
ELSE'S AND ESPECIALLY NOT THE PSU CAC'S!     |    A |

walker@unx.sas.com (Doug Walker) (09/13/90)

In article <90250.211833TEW105@psuvm.psu.edu> TEW105@psuvm.psu.edu writes:
>include# <stdio.h> (or whatever the standard one is>
>
>main
>{
>  char showall;
>
>  printf ("Show all output (y/n)? \n");
>  showall=getchar();
>
>  blah... blah.. blah..
>
>}

Try using fgets() instead of getchar().  It gets a whole line
from input, terminated by a newline character.

char buffer[100];
fgets(buffer, 100, stdin);
if(buffer[0] == 'y' || buffer[0] == 'Y') showall = 1;
else showall = 0;


blah... blah... blah...


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker