Re: allocating mem in a function and assigning a ptr to the first byte of that mem array...
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Wed, 28 Feb 2007 04:10:33 -0500
mast2as@xxxxxxxxx wrote:
I almost apologize to ask this question but I have been starting at
this code for a bit of time and don't understand what's wrong with it.
I am not arguing about the fact it's good or not coding, it's actually
a shorter version of something more complex that i am doing.
Anway the idea is that there's a func Test which takes a pointer to
void argument, allocate some memory, set this memory with some cotent,
assign the ptr to a void to the first byte of this new alloc memory
and returuns. Normally because our argument points to the first byte
of that memory array * AND THAT THE MEM HASN'T BEEN FREED *, i should
still be able to access the content of that mem array.
But i don't it crashes.
Please help,
cheers -mark
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
no such header file.
//#include <map>
#include <string>
no such header file.
If your compiler didn't object to the above, you are using a C++
compiler, which is not a good thing to do to C code.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
.
- References:
- Prev by Date: Re: pointer representation: style or substance?
- Next by Date: Re: How To Implement Timer in C
- Previous by thread: Re: allocating mem in a function and assigning a ptr to the first byte of that mem array...
- Next by thread: Re: allocating mem in a function and assigning a ptr to the first byte of that mem array...
- Index(es):
Relevant Pages
|