Re: Struct assignment



Serve Lau wrote, On 30/06/07 19:53:
"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx> wrote in message news:hhfil4xnvp.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxx
Grey Alien wrote, On 30/06/07 17:43:

<snip>

1). is b.s now ptr to a.s ? (I think so)
Since b.s was not defined as a pointer, what makes you think an assignment could magically transform it from being an array in to being a pointer? You need to read section 6 of the comp.lang.c FAQ at http://c-faq.com/ specifically the questions dealing with whether pointers and arrays are the same thing.

Its easy to see where the confusion comes from. There are situations where pointers degenerate into pointers , the OP probably had that in mind

In my opinion it is only easy to confuse arrays and pointers if it is badly taught. If arrays and pointers are taught as fundamentally different concepts and *then* the way array names degenerate to pointers to the first element is explained there will not be anything like the problems. In one-to-one sessions I've been able to explain the basics of arrays pointers to non-computer people in minutes (I needed to so I could explain approximately what was the cause of a problem), although I did not go on to how things are done in C.
--
Flash Gordon
.



Relevant Pages

  • Re: Array comparison
    ... > Deep and recursive. ... the pointers and comparing their referents instead of comparing the ... >> arrays, then I think you also need to argue against assigning arrays. ... semantics (notably, reference counting). ...
    (alt.comp.lang.borland-delphi)
  • Re: double pointer
    ... Nor is it up to me, Deitel 1, Deitel 2, Schildt, ... that arrays are pointers, or that pointers are arrays, in C++. ...
    (comp.lang.c)
  • Re: Doubt about arrays name
    ... basicly pointers are arrays and arrays are pointers, ... but "int main" is better. ... In this case, for traversing a string, using int can't ...
    (comp.lang.c)
  • Re: new IL: C (sort of...).
    ... about the fact that in PIC's C you can't have arrays larger than 256 bytes. ... Its pointers are rudimentary) Its semantics are rather Delphi than C. ... This goes nearly for any static compiled imperative language. ... result of some minor memory saving in the original compiler or to its funky ...
    (comp.lang.misc)
  • Re: low-level pointer vs. array question
    ... arrays, I was not aware of this: ... pointers and arrays, ... it is indeed a platform (and compiler) ...
    (comp.lang.c)