Mike Wahler wrote:
> "Frank Mikkelsen" <> wrote in message
> news:42cc272e$0$21463$ ...
> >
> > "Mike Wahler" <> skrev i en meddelelse
> > news:YCRye.13635$ hlink.net...
> >>
> >> "chellappa" <> wrote in message
> >> news: oups.com...
> >>> please give some examples
> >>
> >> Please preserve context when posting. Thank you.
> >>
> >> Please get a textbook. You won't get far without
> >> one.
> >>
> >>
> >> "Chris Dollin" <> wrote in message
> >> news:dagmtd$lrl$...
> >>> chellappa wrote:
> >>>
> >>>> please explain me , char pointer , char Array, char ,string...
> >>>
> >>> A decent book on C will explain all this, and be faster than
> >>> drip-feeding via Usenet. But:
> >>>
> >>> A `char pointer` is a pointer that points to characters.
> >>> A `char array` is an array whose elements are characters.
> >>> A `char` is a value which is/represents a character.
> >>> A `string` is a sequence of characters terminated by a
> >>> null (== 0) character.
> >>>
> >>> [A `sequence of characters` is a contiguous slice out of an
> >>> array or mallocated store.]
> >>
> >> "chellappa" <> wrote in message
> >> news: oups.com...
> >>> please give some examples
> >>
> >> char *p; /* 'char pointer' (a.k.a. 'Pointer to char'). */
> >> / * can represent address of a type 'char' object */
> >>
> >> char a[10]; /* 'char array' (a.k.a. 'array of char'). */
> >> /* can store ten type 'char' objects at */
> >> /* contiguous memory locations */
> >>
> >> char c; /* a type 'char' object. Can represent any one */
> >> /* of the values of the execution character set */
> >>
> >> char s[10] = "Hello" ; /* 'char array' (a.k.a. 'array of char'). */
> >> /* The first six elements of the array */
> >> /* (s[0] through s[5] inclusive) comprise */
> > wrong !! the: char s[10] = "Hello" assign 7 elements,
>
> Really? Please explain.
>
> (BTW that definition dos not 'assign' anything, it
> *initializes* the first six characters of the array.
> Initialization and assigment are not the same thing.)
>
>
> > donīt forget the zero termination of the string at position
> > s[7]
>
> I did not forget about the terminator, but it's location
> is s[5]. None of s[6] through s[9] have been initialized or
> assigned a valid value.
Actually, s[6] through s[9] *have* been initialized to '\0'.
Robert Gamble
|