Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Aug 2014 02:37:49 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG>
Subject:   Re: how to grab text w/ fcanf
Message-ID:  <20140801023749.8752a6b8.freebsd@edvax.de>
In-Reply-To: <20140731233335.GA24151@ethic.thought.org>
References:  <20140731233335.GA24151@ethic.thought.org>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Thu, 31 Jul 2014 16:33:35 -0700, Gary Kline wrote:
> 	what is the easiest way, in C, *knowing the count=N*, to
> 	grab the *text files and stuff the paragraphs into a global
> 	buffer:	char *parabuffer[1024]; ??

Addition:

For every _desired_ file name you've obtained, do the
following: fopen() the file in "r" mode, fgets() the
line (or each line) into a read buffer, maybe postprocess
the buffer, and then append it to the parabuffer. Use
strlcat() to make sure you're not crossing the edge of
the string, so allocate sufficient space. Finally fclose()
the file when feof() tells you that the end has arrived.
THEN GOTO NEXT. :-)

See "man strcat" on why not to use strcat() or strncat(),
section SECURITY CONSIDERATIONS.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20140801023749.8752a6b8.freebsd>