Date: Thu, 6 May 1999 17:13:41 -0400 Message-Id: <199905062113.RAA27742@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: <199905062054.PAA15797@darwin.sfbr.org> (message from Jeff Williams on Thu, 6 May 1999 15:54:44 -0500 (CDT)) Subject: Re: OT: skip remainder of input line following `#' ? References: <199905062054 DOT PAA15797 AT darwin DOT sfbr DOT org> Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > The recent exchange regarding fflush(stdin) got me wondering if there > is an equally clever way (i.e., using the scanf format specifications) > to skip the remainder of an input record if a # symbol is encountered > (e.g., so that comments could be appended to the end of fixed (except > for white space) format data records). What I always do is read in a whole line at a time with fgets(), then parse it with sscanf(). You can use strchr(string, '#') to find any '#' and set it to '\0' instead, before calling sscanf.