[comp.lang.c] Memory Access

Peter_Warren_Lee@cup.portal.com (12/14/90)

I'm just starting out learning C and I'm looking for some help. Are there
some commands in C that work like PEEK and POKE in BASIC? I'd like to
be able to see the values in a range of memory but I can't find the
right commands to do it.
Thanks,
                              Pete
  Peter_Warren_Lee@cup.portal.com

jdb@reef.cis.ufl.edu (Brian K. W. Hook) (12/15/90)

Well, assuming that you are on a non protected mode machine (ie. IBM PC)
that lets you read into any absolute memory address, you can use standard
C pointers to read in individual characters.  However, for large memroy
locations (locations outside of your segment) you needs to uses a 
FAR pointer.  Read the documentation on MK_FP, FP_SEG, and FP_OFF for
more on that.  I suppose that you could use memcpy to copy a specified
amount of memory and then you could examine it later as a string....
Turbo C have a poke and peek function built in, but this assumes that you
are using TC on a DOS machine.

hotte@sunrise.in-berlin.de (Horst Laumer) (12/17/90)

Peter_Warren_Lee@cup.portal.com writes:

>I'm just starting out learning C and I'm looking for some help. Are there
>some commands in C that work like PEEK and POKE in BASIC? I'd like to
>be able to see the values in a range of memory but I can't find the
>right commands to do it.
>Thanks,
>                              Pete
>  Peter_Warren_Lee@cup.portal.com

Just look at <memory.h>, and then provide the proper addresses.
Works great on MS-DOS, but you surely run into trouble when f.e.
trying to write to fixed adresses on a UNIX-System outside the
address-space of your program.

--HL

-- 
============================================================================
Horst Laumer, Kantstrasse 107, D-1000 Berlin 12 ! Bang-Adress: Junk-Food 
Domain: hotte@sunrise.in-berlin.de              ! for Autorouters -- me --
Bang:   ...unido!fub!geminix!sunrise.in-berlin.de!hotte