------------
When passing parameters to a function, generally, when passing a non-const pointer, it indicates that the pointer needs to be modified in the function to refer to the data in the memory. If the value is passed, no matter how this value is modified inside the function, it does not affect the passed value, because the passed value is only copied to the memory.
What? You understand this feature. Okay, let's take a look at the following routine:
Void
Getversion (char * pstr)
{
Pstr = malloc (10 );
Strcpy (pstr, "2.0 ");
}
Main ()
{
Char * ver = NULL;
Getversion (VER );
...
...
Free (VER );
}
I promise that such a problem is the easiest mistake for a newbie.ProgramIn the attempt to allocate space to the pointer ver through the getversion function, but this method does not have any function at all, because -- this is to pass the value, not to pass the pointer. Maybe you will argue with me. What is the pointer when I tell you? Let's take a closer look. In fact, the pointer is actually passing the value.