On Fri, Jun 29, 2001 at 05:01:19PM +0200, mldb wrote:
> RC> From: Rodolfo Cazabon <rod...@au...>
>
> RC> Hi everyone...
> [snip]
> RC> Second, I cheated, and declared these as PUBLIC...but when I do the
> RC> following :
>
> RC> ClassListIterator cli(p_groupDef->classList);
> RC> ClassDef *cd;
> RC> for (cli.toFirst();(cd=cli.current());++cli)
> RC> {
> RC> printf("%S \n", cd->name() );
> RC> }
>
> RC> I get a crash because that pointer is not valid!
>
> I suspect, you missed the fact, that printf has a vararg signature
> (printf(const char *fmt,...)). The "const char *" conversion of
> QCString (this is what cd->name() is) is not used, since the compiler
> does not know *to what* you want it to be converted: '...' could be
> anything.
>
> printf("%s \n", (const char*)cd->name());
Or alternatively,
printf("%s \n", cd->name().data());
which I prefer myself.
Regards,
Dimitri
|