\0 means the NULL character. In ASCII, that is a character whose code is 0x00. It is usually used to indicate the end of a character string. A function that prints characters typically looks for this character and stops printing when it finds it, since this means the end of the string.
What you mean cannot modify the pointer or the char that it points to. Please can you give some simple sample so that i can try it and i can more understand it..
So, for this function how can i declare the function prototype?
Here is an example of violating both const qualifiers:
Code:
void PC_LINK_O_Write_String_To_Buffer(const char* const STR_PTR)
{
STR_PTR = 0; // attempt to modify the pointer
*STR_PTR = 0; // attempt to modify what it points to
}
If I attempt to compile that in gcc, it emits errors for lines 3 and 4: test.c: In function `PC_LINK_O_Write_String_To_Buffer':
test.c:3: error: assignment of read-only location
test.c:4: error: assignment of read-only location
The prototype for that function is simply: void PC_LINK_O_Write_String_To_Buffer(const char* const);
void PC_LINK_O_Write_String_To_Buffer(const char* const STR_PTR)
{
STR_PTR = 0; // attempt to modify the pointer
*STR_PTR = 0; // attempt to modify what it points to
}
I still not understand the "void PC.....(const char* const STR_PTR)", why they declare const char* const, what is this mean the const char* combine with const
i just know if :
char amessage[] = "hello"; // array, element will store in storage (individual character within the array may be changed)
char *pmessage = "hello"; // pmessage is initialize to point to a string constant (cannot modify the string contents)
Can you give the simple complete program for this const char* const example??