delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/15/13:33:06

Date: Wed, 15 Sep 1999 12:02:18 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Batchex <thedark1 AT Phreaker DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: invalid operands
In-Reply-To: <1684.990913@Phreaker.net>
Message-ID: <Pine.SUN.3.91.990915120158.27871Q-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 13 Sep 1999, Batchex wrote:

>   char **lpszTable;
[snip]
>   for(nIdx=1;nIdx<nNumEntries;nIdx++)
>    lpszTable[nIdx]=(char *)(lpszTable[0]+(lpszTable[nIdx]-lnDataStart));
[snip]
> 
>   The last line of the code always gives me "invalid operands for
>   binary +".

lpszTable is a pointer to a pointer.  Therefore, lpszTable[0] and
(lpszTable[nIdx]-lnDataStart) are both pointers.  You cannot add two
pointers in C.  That's what the compiler keeps telling you.

>   One other question, not related to the above code, anybody know any
>   function that can read raw data from file (like _dos_read()) that is
>   POSIX compliant? fread() seems to stop whenever it encounter CR/LF
>   pair ("\n"), and my data have a lot of them.

Use the "b" specifier when you open the file, like this:

    FILE *fp - fopen ("filename", "rb");

And no, _dos_read is not Posix.  The DJGPP library docs explicitly
tell which functions are ANSI- and Posix-compliant and which aren't.
Please use that information, it is there for you.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019