Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sol.ctr.columbia.edu!emory!gatech!uflorida!trout.cis.ufl.edu!sml From: sml@trout.cis.ufl.edu (Shein-Fong Law) Newsgroups: comp.lang.c Subject: Problem with gets Message-ID: <25227@uflorida.cis.ufl.EDU> Date: 2 Nov 90 08:22:09 GMT References: <942@babcock.cerc.wvu.wvnet.edu> <2655@dsacg3.dsac.dla.mil> Sender: news@uflorida.cis.ufl.EDU Reply-To: sml@trout.cis.ufl.edu (Shein-Fong Law) Organization: UF CIS Department Lines: 47 I am having troubles with using gets function. Here is the situation: void function() { char input[40]; while (.....) /* loop begins */ { .. some code printf(" enter value %s\n",value); gets(value); ..... } /* end of while */ } My problem is the first time I entered the while loop , both printf and gets statements are not executed.But after that everything is o.k. What I want is using a loop to prompt input from the user and get the value. For eaxmple, if there are 5 values to be entered (determined by while loop test ), I will prompt 5 times and at the same time get 5 values. Is there anything wrong ? I have put some more printf statements just before gets, and find that when I enter the loop for the first time, these print statements are excuted, but gets is still not executed. It seems that gets sees the EOL charater whenever I enter the loop for the first time. Any advice or help is greatly appreciated . Is there a better and more reliable way to do what I need ? Thanks in advance. If possible, please email to me. Shein-fong Law sml@beach.cis.ufl.edu