Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C Programming Tutorial on Youtube Date: Wed, 12 Oct 2016 12:06:21 -0700 Organization: None to speak of Lines: 54 Message-ID: References: <8be0cdbe-c2f4-42ec-b6a7-e9a154981718@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="dda83c6a599b9ea966ac051ddb4678f6"; logging-data="21716"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rS0PHqBDpjOBHqqPnIaF1" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:gDYplpb9UsO9R2uiX1Ha/AU6JTM= sha1:1pxhRepb195wbG/pO/njR9HJgqw= Xref: csiph.com comp.lang.c:94789 BartC writes: > On 12/10/2016 16:53, Richard Heathfield wrote: >> On 12/10/16 16:44, BartC wrote: > >>> So? Someone might want to have a constant pointer to a block of ints. >> >> Non sequitur. int buff[1024] is not a constant pointer to a block of >> ints. If someone wants a constant pointer to what you call a "block" of >> ints (and it isn't clear to me what you mean by a "block"), > > Make a wild guess. > > they will >> need to define a constant pointer to a "block" of ints. The definition >> int buff[1024]; will not give them that. > > We're talking about a contiguous sequence of 4096 bytes in what might be > called 'bss' or 'text' memory, depending whether it's initialised, the > starting address of which is fixed at link or load time. Bss? Text? What are those? (That's rhetorical, don't bother answering.) Those are mechanisms used by some implementations to *implement* C semantics. If you want to introduce a new learner to C by discussing how C source code is mapped to lower level concepts, you can do that. I personally don't think it's the best approach. C source specifies *behavior*. Generated machine code is a tool used to implement that behavior. > This is what 'int buff[1024]' in C gives you, which is exactly the same > thing, when you get down to fundamentals, as a constant pointer to a > block of 1024 ints. No, it's not a pointer to a block. It *is* the block. It happens to be easy to construct a pointer value that points to the beginning of that block. If you define int n = 42; it's nearly as easy to construct a pointer value that points to that int object, but I don't think anyone would suggest that "n" is, when you get down to fundamentals, a constant pointer. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"