Problem with gets
    Shein-Fong Law 
    sml at trout.cis.ufl.edu
       
    Fri Nov  2 19:22:09 AEST 1990
    
    
  
     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 at beach.cis.ufl.edu
 
     
    
    
More information about the Comp.lang.c
mailing list