hello,
i was looking at a program someone wrote.
I saw something like that:
name = (char*) strdup(path);

strdup already returns char *, so why do we need casting here?
did he do a wrong thing or am i wrong?

He didn't do anything "wrong" as such, but there isn't any need to cast it.

Without more code to look at, I can only guess. But my guess is that he didn't include the right header for strdup and casted the result to silence his compiler's warnings about it.

thanks very much for the answers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.