Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #75139

Re: Pointers: misunderstanding

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Pointers: misunderstanding
Date 2015-11-06 17:53 +0000
Organization A noiseless patient Spider
Message-ID <87a8qrvwu2.fsf@bsb.me.uk> (permalink)
References (2 earlier) <4b008308-c735-4da8-b946-533409f02cc5@googlegroups.com> <87d1vnxooe.fsf@bsb.me.uk> <046d6331-ce76-4ecf-8b73-dd307ba46a74@googlegroups.com> <n1im7h$c2u$1@dont-email.me> <fa2e5227-3fb9-482c-ab85-3c6751e143c8@googlegroups.com>

Show all headers | View raw


Alla _ <modelling.data@gmail.com> writes:

>> > *pointer_1 has a type of a pointer to an integer, as pointer_2 and temp.
>> > Do you mean that to declare *temp I need to allocate a memory for it with
>> > malloc?
>> 
>> Don't even *think* about that yet.
>
> Too late :) It's been already part of the lecture (CS50 one) I've listened,
> and part of some very simple exercises they offered. Doing problem set I 
> have to use malloc. If I understood it correctly, but happily forgotten, until
> Ben has reminded (though, I am not sure Ben was talking about this) me, 
> whenever I declare a variable of a pointer type that doesn't point anywhere
> yet, I have to allocate a memory for it with malloc. As with temp,
> int* temp = malloc(sizeof(int))?

I've answered elsewhere, but no.  You don't need to do that at all.
malloc should not be involved in this exercise.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-05 09:09 -0800
  Re: Pointers: misunderstanding Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-05 17:44 +0000
    Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 00:49 -0800
      Re: Pointers: misunderstanding Philip Lantz <prl@canterey.us> - 2015-11-06 03:01 -0800
        Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 03:09 -0800
  Re: Pointers: misunderstanding Barry Schwarz <schwarzb@dqel.com> - 2015-11-05 11:40 -0800
  Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 03:08 -0800
    Re: Pointers: misunderstanding Richard Heathfield <rjh@cpax.org.uk> - 2015-11-06 11:33 +0000
    Re: Pointers: misunderstanding Keith Thompson <kst-u@mib.org> - 2015-11-06 08:53 -0800
  Re: Pointers: misunderstanding Philip Lantz <prl@canterey.us> - 2015-11-06 03:16 -0800
    Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 03:30 -0800
      Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 03:32 -0800
        Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 04:58 -0800
          Re: Pointers: misunderstanding Keith Thompson <kst-u@mib.org> - 2015-11-06 09:00 -0800
            Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 09:25 -0800
            Re: Pointers: misunderstanding supercat@casperkitty.com - 2015-11-06 10:07 -0800
              Re: Pointers: misunderstanding Keith Thompson <kst-u@mib.org> - 2015-11-06 12:31 -0800
              Re: Pointers: misunderstanding Philip Lantz <prl@canterey.us> - 2015-11-06 20:08 -0800
        Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 04:59 -0800
      Re: Pointers: misunderstanding Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-06 13:06 +0000
        Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 08:50 -0800
          Re: Pointers: misunderstanding Richard Heathfield <rjh@cpax.org.uk> - 2015-11-06 17:00 +0000
            Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 09:17 -0800
              Re: Pointers: misunderstanding Richard Heathfield <rjh@cpax.org.uk> - 2015-11-06 17:22 +0000
                Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 09:29 -0800
              Re: Pointers: misunderstanding Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-06 17:53 +0000
            Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 09:22 -0800
              Re: Pointers: misunderstanding Richard Heathfield <rjh@cpax.org.uk> - 2015-11-06 17:24 +0000
                Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 09:33 -0800
                Re: Pointers: misunderstanding Richard Heathfield <rjh@cpax.org.uk> - 2015-11-06 18:29 +0000
                Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 23:42 -0800
            Re: Pointers: misunderstanding Philip Lantz <prl@canterey.us> - 2015-11-06 20:24 -0800
          Re: Pointers: misunderstanding Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-06 17:51 +0000
            Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 23:37 -0800
              Re: Pointers: misunderstanding Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-07 13:36 +0000
                Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-07 08:17 -0800
                Re: Pointers: misunderstanding Philip Lantz <prl@canterey.us> - 2015-11-07 12:04 -0800
    Re: Pointers: misunderstanding Keith Thompson <kst-u@mib.org> - 2015-11-06 08:55 -0800
      Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 09:23 -0800
  Re: Pointers: misunderstanding Philip Lantz <prl@canterey.us> - 2015-11-06 03:26 -0800
  Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 23:48 -0800
    Re: Pointers: misunderstanding Barry Schwarz <schwarzb@dqel.com> - 2015-11-07 00:35 -0800
  Re: Pointers: misunderstanding Alla _ <modelling.data@gmail.com> - 2015-11-06 23:48 -0800
    Re: Pointers: misunderstanding Keith Thompson <kst-u@mib.org> - 2015-11-07 12:24 -0800

csiph-web