Mail Archives: djgpp/1997/10/31/11:32:03
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 -