![]() |
|
#1
|
|||
|
|||
Determining memory size in C?i have a little code for determing memory size this my code:
CPP / C++ / C Code:
Last edited by LuciWiz : 01-Jun-2009 at 09:31.
Reason: Please insert your C code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: memory size in C?Hello aska,
I just Googled around and came across your thread. The biosmemory is only compatible with DOS and Windows 3.x. Look at this page for more information: http://www.digitalmars.com/rtl/bios.html#_bios_memsize As for any solution for your problem, I don't really know. What memory are you going to read? System memory (RAM) or some cache of some sort? |
|
#3
|
|||
|
|||
Re: memory size in C?I'm going to read system memory (RAM).
|
|
#4
|
|||
|
|||
Re: memory size in C?Quote:
There are no standard C or C++ library functions that deal with hardware considerations (ram, video display, etc.) There may be operating-system dependent functions available with your compiler. For example, on my Windows xp platform with Microsoft and Borland compilers I can use the following, based on an example from msdn: CPP / C++ / C Code:
If your workstation has one GByte of memory installed, you can expect to see something like: Code:
If you are running Linux, you can get the information from /proc/meminfo. With my various Linux workstations, I can just open /proc/meminfo as a file and read a line at a time into a buffer until I see the line that begins with "MemTotal:" Then I use sscanf to read the second item into an unsigned long variable. Regards, Dave Footnote: The "/proc/meminfo" stuff also works for me with GNU gcc on my Windows/Cygwin workstation. If you have some compiler other than GNU or a fairly recent Microsoft or Borland compiler or if you are using some other operating system there may be (or, maybe not) similar (or dissimilar) functions. In other words, any time you need non-standard functions for your task: YMMV (Your Mileage May Vary). |
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A Complete Guide to SD Memory Cards | haulkook | Computer Hardware Forum | 0 | 02-Jul-2008 00:27 |
| A Few Tips on Buying Good Memory Cards and other Hi-Tech Electronic Accessories | haulkook | Computer Hardware Forum | 0 | 02-Jun-2008 04:53 |
| Hard drive/CPU Diagnoses Issues | binarybug | Computer Hardware Forum | 1 | 22-Jan-2007 20:23 |
| [Tutorial] Pointers in C (Part I) | Stack Overflow | C Programming Language | 1 | 08-Apr-2005 19:35 |
| Having a problem | Chuckles | Computer Hardware Forum | 19 | 13-Sep-2004 13:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The