Please Help!
I am using this structure :
typedef struct Sname
{
char *pSzfirst;
char *pSzLast;
struct name *Snext;
This is perfectly all right, but almost certainly not what
you intended. I strongly suspect that you mean `struct Sname'
here, or else that you meant `struct name' above. I also strongly
suspect that the code you have shown us is not the code that's
giving you trouble; it follows that our diagnoses and suggestions
may be wide of the (hidden) mark, and if so, that you have no one
but yourself to blame for our inaccuracies.
Where is the identifier the `typedef' declares? And where is
the semicolon that concludes the declaration? I'm going to proceed
on the assumption that `person;' comes after the `}', and if my
assumption is wrong -- well, again, it's your fault.
person* FindMin (person *pSHead)
{
person *pSMin;
person *pSCurr;
pSMin=pSHead;
pSCurr=pSHead;
while (pScurr!= NULL)
{
if (strcmp(pScurr->pszfirst,pSMin->pszfirst)<0)
This shakes my faith in my assumption that `struct Sname' and
`person' are the same thing. The problem is that `struct Sname' has
no element named `pszfirst', so the compiler would have complained.
But perhaps `person' is something entirely different, something that
*does* have a `pszfirst' element? Perhaps. But my bet is that you
are showing us something other than your actual code.
{
pSMin=pSCurr;
}
pSCurr=pScurr->Snext;
This is the basis of my guess that `person' is an alias for
`struct Sname'. If it were not, the compiler would complain here --
unless both `person' *and* `struct Sname' have an element named
`Snext', which is possible but not especially plausible.
What is `psMin'? You've shown us a `pSMin', but that's not the
same thing at all.
} //Error:Expected a declaration! What can I do to make this work?
Could somebody please write a piece of code that will walk the list?
I could certainly write code that will walk *a* list, but since
I don't see solid evidence in yours of the existence of anything one
might call *the* list, then no: I cannot write the code. If you need
assistance, please try again -- with the *exact* and *complete* code
that's giving you trouble, and not with an inaccurate paraphrase.