Hi,how do we use perror? Does it only prints out the error message?
If so , why don't we use printf instead?

Thanks.

Do you know why some fopen call failed? Using perror might give a better error message, like "no such file or directory", "permission denied", or "too many open files".

But sure, you could also do something like this.

puts(strerror(errno));
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.