Hi Terry,
> I did say my knowledge of C / C++ is 'Janet and John', but I suspect
> that I never even made that grade !
`const' didn't exist when I started C, probably not for you either. It
isn't in K It was added by the X3J11 committee as part of ANSI
standardisation that became C89, AKA C90.
On Sunday, 21 January 2018 16:23:56 GMT Ralph Corderoy wrote:
> `k' is already a `const char *' so the cast to the same thing looks
> redundant. Because that parameter is a const, I think the first version
> is picked, it returns a `const char *', but it's being assigned to `p'
> that's a
Hi Terry,
> > Looking at the use of `p', I suggest making that a const too.
>
> I didn't spot this yesterday, but that won't work because p is used as
> a variable within that function.
Have you tried it? :-)
int GetDValue(const char *k)
{
char *p = strrchr((char *)k, 'D');
On Monday, 22 January 2018 12:14:21 GMT Ralph Corderoy wrote:
> > I didn't spot this yesterday, but that won't work because p is used as
> > a variable within that function.
>
> Have you tried it? :-)
>
> int GetDValue(const char *k)
> {
> char *p = strrchr((char *)k, 'D');
>
On Monday, 22 January 2018 12:38:33 GMT Ralph Corderoy wrote:
> `const' didn't exist when I started C, probably not for you either. It
> isn't in K It was added by the X3J11 committee as part of ANSI
> standardisation that became C89, AKA C90. K has it.
Yes. I started with plain ol' K, in
On Monday, 22 January 2018 13:21:42 GMT Terry Coles wrote:
> Thinking about what you said about this usage:
> > `const char *p' means p is a pointer to a char that's const.
Rereading your original post, I think I've now caught on.
> What does that actually mean in terms of what it points at?
>
Hi Terry,
> > `const char *p' means p is a pointer to a char that's const.
>
> What does that actually mean in terms of what it points at? Obviously
> p cannot be a char because it is incremented and the pointer is
> containing a memory address, so what is char in this case?
You're right, p
7 matches
Mail list logo