Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!sunybcs!sbcs!bnlux0!baron From: baron@bnlux0.bnl.gov (ed baron) Newsgroups: comp.lang.c Subject: learning c Keywords: getchar() Message-ID: <1091@bnlux0.bnl.gov> Date: 1 Apr 89 15:40:44 GMT Distribution: usa Organization: Brookhaven National Lab Lines: 32 Maybe this isn't the best place to post this but it seemed reasonable. I am trying to learn c out of a book that seems to be wrong on many things, but anyway i can't seem to figure out how getchar() should work. consider the following char name [10]; int c; for(;;) { puts("enter 9 to exit"); c = getchar(); if(c == 9) break; puts("enter name: "); gets(name); . . . } now getchar gets one character but not until it sees the terminator (carriage return) but since it only gets one character and the carriage return is one character if you enter 1 say the is passed to the next thing seeking input and so now name is just i.e there is no opportunity to respond to the naame prompt. then i tried using gets(c) in place of getchar c (andd declaring c to be char) but that won't compile. what is the proper way to do this? please respond via mail. thanks. ed baron (baron@bnlux0.bnl.gov, baron@bnlux0.bitnet)