[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] gets strengen



Sune Fischer <sslug@sslug> writes:

> > > char *linein;
> > > gets(linein);
> > 
> > gets() er farlig - læs man-siden! Brug fgets i stedet.
> 
> tjoo, linein er på 300 bytes, så lange kommandoer kommer der ikke.
> Med fgets får jeg det omvendte problem, den skal have antallet af
> bytes der skal læses, det antal kender jeg jo ikke. 
> Hvad sker der hvis jeg læser 300 bytes fra stdin, når der kun sendes
> 20?

rtfm (fra man fgets:
       fgets()  reads  in  at  most one less than size characters
       from stream and stores them into the buffer pointed to  by
       s.  Reading stops after an EOF or a newline.  If a newline
       is read, it is stored into the buffer.  A '\0'  is  stored
       after the last character in the buffer
)

-- 
Mvh
Rasmus Meldgaard
sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *