Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > fgets problem...

fgets problem...
Thread Tools
Mac Elite
Join Date: Jun 2000
Location: Pasadena
Status: Offline
Reply With Quote
Jul 27, 2002, 03:25 AM
 
According to <a href="http://developer.apple.com/technotes/tn/tn1176.html" target="_blank">Apple</a>, fgets is supported since OS 9 thanks to StdCLib 3.5, now located in /system/library/cfmsupport/.
However, in Project Builder 1.1.1 (OS X.1.5), using the following headers:
#include &lt;Carbon/Carbon.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;
#include &lt;math.h&gt;
it doesn't seem like fgets() supports Mac's &lt;CR&gt; only style. Tracing through code, my buffer is entirely filled, with '\r' (ASCII value 13) where new lines in the orginal document are at. Looping it again will fill my buffer with values following the previous buffer, again, the buffer is entirely filled instead of properly terminated.
Any ideas? ^_^;

<small>[ 07-27-2002, 02:01 PM: Message edited by: Evangellydonut ]</small>
G4/450, T-bird 1.05GHz, iBook 500, iBook 233...4 different machines, 4 different OSes...(9, 2k, X.1, YDL2.2 respectively) PiA to maintain...
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Jul 28, 2002, 05:34 PM
 
Hmm, not sure... Perhaps you should read in the entire file and then use something like strtok() if it's not too large?

(Or write your own fgets() that keeps fgetc()ing until a \r occurs?)

<small>[ 07-28-2002, 06:35 PM: Message edited by: parallax ]</small>
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2