Article View: alt.msdos.programmer
Article #231Re: Turbo C far pointers
From: Jim Wright
Date: Sat, 28 Oct 1989 19:08
Date: Sat, 28 Oct 1989 19:08
36 lines
1367 bytes
1367 bytes
In a recent posting elrond@titan.tsd.arlut.utexas.edu (Brad Hlista) writes:
| I am having a problem of getting an allocated block of far memory
| to return float values. Here is how variables are declared and dereferenced:
| far *ptr;
I think this is the big part. An int pointer is not the same as a float
pointer. The following program works for me (MSC).
#include <stdio.h>
#include <malloc.h>
int main(void);
int main()
{
int i;
float far *start;
float far *p;
start = (float far *) _fmalloc(1000*sizeof(float));
if (start != NULL) {
printf("Good.\n");
for (p=start,i=0 ; i<1000 ; i++)
*(p++) = 3.1415927;
for (p=start,i=0 ; i<10 ; i++)
printf("%f\n", *(p++));
}
else
printf("Oh shit.\n");
return(0);
}
--
Jim Wright
jwright@atanasoff.cs.iastate.edu
Technical Details
Message-ID:
<1711@atanasoff.cs.iastate.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!dino!atanasoff!jwrightReferences:
<565@titan.tsd.arlut.utexas.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!dino!atanasoff!jwright From: jwright@atanasoff.cs.iastate.edu (Jim Wright) Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc Subject: Re: Turbo C far pointers Message-ID: <1711@atanasoff.cs.iastate.edu> Date: 28 Oct 89 19:08:15 GMT References: <565@titan.tsd.arlut.utexas.edu> Reply-To: jwright@atanasoff.cs.iastate.edu (Jim Wright) Organization: Iowa State U. Computer Science Department, Ames, IA Lines: 36