Re: What does const char *s mean? is s a constant or *s?
From: pete (pfiland_at_mindspring.com)
Date: 01/24/05
- Next message: Jonathan Burd: "Re: What does const char *s mean? is s a constant or *s?"
- Previous message: Eltee: "Re: c99 on Microsoft Visual Studio"
- In reply to: G Patel: "What does const char *s mean? is s a constant or *s?"
- Next in thread: Jonathan Burd: "Re: What does const char *s mean? is s a constant or *s?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 24 Jan 2005 09:00:37 GMT
G Patel wrote:
>
> I've been looking at some code for string functions (certain
> implementation of them) and the non modified
> string is usually declared as a const char *s in the parameter list.
A const char *s in the parameter list means that you should
expect the function not to change the string that s points to,
even though the function still could do that
by casting away the const qualifier.
char *str_cpy(char *s1, const char *s2)
{
char *const p1 = s1;
do {
*s1 = *s2++;
} while (*s1++ != '\0');
return p1;
}
-- pete
- Next message: Jonathan Burd: "Re: What does const char *s mean? is s a constant or *s?"
- Previous message: Eltee: "Re: c99 on Microsoft Visual Studio"
- In reply to: G Patel: "What does const char *s mean? is s a constant or *s?"
- Next in thread: Jonathan Burd: "Re: What does const char *s mean? is s a constant or *s?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|