:: Re: [DNG] Making sense of C pointer…
Página Principal
Delete this message
Reply to this message
Autor: Emiliano Marini
Data:  
Para: Rainer Weikusat
CC: dng
Assunto: Re: [DNG] Making sense of C pointer syntax.
I was wrong because in this examples p was a pointer to int. Sorry, I was
thinking on something like this:

int *p;
*p = 0;

Cheers,
Emiliano.

On Mon, Mar 28, 2016 at 2:16 PM, Emiliano Marini <emilianomarini82@???
> wrote:


> You're right.
>
> On Mon, Mar 28, 2016 at 2:04 PM, Rainer Weikusat <
> rainerweikusat@???> wrote:
>
>> Emiliano Marini <emilianomarini82@???> writes:
>> > char *p;
>> > p="01234"; /* skeezy, but makes the point */
>> >
>> > Warning! Here "p" is pointing to nowhere, you don't know which memory
>> > locations are writing to.
>>
>> The 'memory location' (if any) reserved for the pointer p itself by the
>> compiler, IOW, this is totally correct.
>>
>> >
>> > char *p;
>> > *p=malloc...*
>> > p="01234"; /* skeezy, but makes the point */
>>
>> And this is a memory leak as the pointer returned by malloc is
>> overwritten.
>> _______________________________________________
>> Dng mailing list
>> Dng@???
>> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
>>
>
>