In the following code I get a segmentation fault:
Set *getpar() {...}
char function(...)
{
Set **S;
*S = getpar(); /* Segmentation Fault */
...
}
But the bizarre thing is that with few changes there is no segmentation fault:
Set *getpar() {...}
...
char function(...)
{
Set *S; // One less '*'
S = getpar(); // One less '*'
...
}
As I know, if there is a 'Set **S
' then *S
is a pointer to a Set
object, so if the second code works fine, why shouldn't the first? *S
of the first code is equivalent to S
of the second code, am I not right? How can I solve the problem?