delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/21/19:27:10

From: "DeHackEd" <notgiven AT out DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <36D00BD6 DOT A01E4BBB AT erols DOT com>
Subject: Re: Physical Memory - Newbie question....
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.0810.800
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800
Message-ID: <m51A2.3770$a02.265@cabot.ops.attcanada.net>
Date: Sun, 21 Feb 1999 18:58:54 -0500
NNTP-Posting-Host: 142.194.222.238
X-Trace: cabot.ops.attcanada.net 919641554 142.194.222.238 (Sun, 21 Feb 1999 23:59:14 GMT)
NNTP-Posting-Date: Sun, 21 Feb 1999 23:59:14 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Jason Mullins <cyberj23 AT erols DOT com> wrote in message
news:36D00BD6 DOT A01E4BBB AT erols DOT com...
>Hello All -
>
>After reading some of the posts about physical memory, I tried to make
>this work myself...  I didn't have a lot of luck.  I'm also very new to
>programming....
>
>How can I make the function print the return value on the screen?  i.e.
>printf("Here is your physical memory\n"); etc...  here is what I have so
>far, but I think im way OFF :)

Actually you are. That function, _dpmi_go32_and_so_on_and_so_on is already
defined. The proper use of it in 30 seconds or less would be:

#include <stdio.h>
#include <dpmi.h>

int main()
{
    long int bytes;
    float answer;

    // get free memory in bytes
    bytes = _go32_dpmi_remaining_physical_memory();

    // calculate to decimal point megabyte
    answer = (float) bytes / (1024.0 * 1024.0);

    printf("%f megabytes of ram free\n", answer);
    return 0;
}

Don't define that function yourself, it's taken care of in the libraries.



- Raw text -


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