There are tons of C functions available in C++. There’s one that known to all. Yes, I’m talking about printf. But there’s a difference between header in C and in C++. C++ uses the same header names from C, but the .h extensions are removed and c prefix is added in all cases. Also whenever you use a function from the standard library, you have to include std:: namespace.
Now given that, printf is declared in cstdio, the C++ version of stdio.h, should you use printf like this:
Or like this:
The answer is you can choose either one. Check out this answer:
And this comment:
There can be some conflicts for example in case of abs function. So you’re better of using std:: prefixes.
Check out this stackoverflow answer which discusses the topic in great detail.
Sharing is caring. Share this story in...
Share: Twitter Facebook LinkedIn