🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.help
Article #9

Re: Pointer arithmetic in C?

#9
From: Martin Adler
Date: Mon, 21 Aug 1995 10:34
33 lines
1413 bytes
In article <oylerb-2108950012310001@msp1-5.nas.mr.net>,
oylerb@tdkt.skypoint.net (Bill A. Oyler) wrote:

> Hello,
> 
> Back in my Pascal days, I had absolutely no problem writing strings
> (Str255s) to text files.  I would just do something like this:
> 
>         TextToWrite := 'hello, world!';
>         Count := Length(TextToWrite) - 1;
>         OSError := SetFPos(LogFileRefNum, fsFromLEOF, 0);
>         OSError := FSWrite(LogFileRefNum, Count, @TextToWrite[1]);
> 
> What would be the C equivalent of this code??
> 
> Asside from the obvious syntax differences, all I changed was
> "@TextToWrite[1]" to "&TextToWrite + 1".  Is there something more I need
> to do?  I keep getting garble in my text file....
> 
> Thanks!!
> 

Try:
 ...
 OSError = SetFPos(LogFileRefNum, fsFromLEOF, 0);
 OSError = FSWrite(LogFileRefNum, Count,(Ptr) &(TextToWrite[1]));
 ...

this should work, also i didn't try it


Gulpi
= Martin Adler
Technical Details
Message-ID: <adler-2108951234520001@138.244.207.201>
Path: arc1-ca.pugleaf.net!lrz-muenchen.de!NewsWatcher!user
References: <oylerb-2108950012310001@msp1-5.nas.mr.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lrz-muenchen.de!NewsWatcher!user
From: adler@informatik.tu-muenchen.de (Martin Adler)
Newsgroups: comp.sys.mac.programmer.help,comp.lang.c
Subject: Re: Pointer arithmetic in C?
Date: Mon, 21 Aug 1995 12:34:52 +0200
Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
Distribution: world
Message-ID: <adler-2108951234520001@138.244.207.201>
References: <oylerb-2108950012310001@msp1-5.nas.mr.net>
NNTP-Posting-Host: 138.244.207.201