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:20:44 +1100


"Andrey Tarasevich" <andreytarasevich@hotmail.com> wrote in message
news:vrobpatfvpl799@news.supernews.com
> John Carson wrote:
> > "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
>
> I think Dave was talking about the literal. String literal is an
> "array
> of const char" and its 'char' values cannot be changed.
>

You are right. I didn't read the post carefully enough.

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


Relevant Pages

  • STL hash_map and free/delete the key object
    ... key could be more complex (say, a string and an int). ... bool operator()(const char* s1, const char* s2) const ... HOW DO I DELETE THE MEMORY ASSOCIATED WITH THE KEY ...
    (comp.lang.cpp)
  • Re: I need some basic C++ help
    ... >> change the char values. ... it is the location in memory of the ... In pointer terms, ... >> John Carson ...
    (comp.lang.cpp)
  • 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: 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)