cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/31/11:32:03

From: hat AT se-46 DOT wpa DOT wtb DOT tue DOT nl (Albert Theo Hofkamp)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Beginners Question
Date: 31 Oct 1997 12:43:56 GMT
Organization: Eindhoven University of Technology, The Netherlands
Lines: 24
Message-ID: <63cjqc$s2q@tuegate.tue.nl>
References: <3458C5E6 DOT 47D7 AT bergen DOT mail DOT telia DOT com>
Reply-To: a DOT hofkamp AT wtb DOT tue DOT nl
NNTP-Posting-Host: se-46.wpa.wtb.tue.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <3458C5E6 DOT 47D7 AT bergen DOT mail DOT telia DOT com>,
	john kismul <john DOT kismul AT bergen DOT mail DOT telia DOT com> writes:
> I've allocated some memory with malloc.
> 
> How do I transfer data from this memory to somewhere else in memory,
> such as, someother memory I've allocated or an array.

When calling malloc, you gave the memory a type. For example,

int *pInt = malloc(sizeof(int));

pInt is a pointer to an int, and points to the memory. In other words, the
memory is an int and can be adressed as such. For example:

*pInt = i;

copies the value i to the malloc-ed memory.
If you want to move larger pieces of data, have a look at memmove, or memcpy.



Albert
---
Freedom: A Linux-based GNU computer system

- Raw text -


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