Re: I need some basic C++ help

From: John Carson (donaldquixote_at_datafast.net.au)
Date: 11/20/03


Date: Thu, 20 Nov 2003 14:22:37 +1100


"Dave" <better_cs_now@yahoo.com> wrote in message
news:vro7qiktrns332@news.supernews.com
> "John Carson" <donaldquixote@datafast.net.au> wrote in message
> news:3fbc1cc9@usenet.per.paradox.net.au...
> > "Dave" <better_cs_now@yahoo.com> wrote in message
> > news:vro33uncnb3kc8@news.supernews.com
> > >
> > > Oops, sorry, I should have said "array of const char" instead of
> > > "const char
> > > *". So, it's really an array, and *then* that array undergoes a
> > > conversion to a pointer when the compiler encounters "modem".
> > > Finally then, as I said before, a pointer cannot be assigned to an
> > > array...
> >
> > It is not the chars that are const --- if they were you couldn't
> > change the char values. Rather, it is the location in memory of the
> > chars that cannot be changed. In pointer terms, it is like a const
> > pointer to char, i.e., char * const
> >
> >
> > --
> > John Carson
> > 1. To reply to email address, remove donald
> > 2. Don't reply to email address (post here instead)
> >
>
> 2.13.4-1: An ordinary string literal has type "array of n const char"
>
> And indeed, you may not change the characters of a string literal.

My mistake. I misread your post as referring to the array

char name[80];

rather than to the string literal.

-- 
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


Relevant Pages

  • Re: Problem with VS and memcpy...
    ... So I can't enter 0 in an array of char? ... John Carson ha scritto: ... Thus header has a terminating nul character as its first character. ...
    (microsoft.public.vc.language)
  • Re: I need some basic C++ help
    ... it is the location in memory of the ... > of const char" and its 'char' values cannot be changed. ... John Carson ...
    (comp.lang.cpp)
  • Re: How to get a point of array?
    ... char ararch; ... Best Regards, ... the use of 3 as both the row and column dimension may make the ... John Carson ...
    (microsoft.public.vc.language)
  • Re: How to convert from string to char*?
    ... The question is what you want to do with that char*. ... In practice, this may work, but it is not a supported use in terms of the ... but not with a string). ... John Carson ...
    (microsoft.public.vc.language)
  • Re: Segmentation fault
    ... Here you ask for a pointer to char. ... to a random position in memory. ... There's nothing else than a string the user could enter;-) ... to the use of scanf(). ...
    (comp.lang.c)