Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query related to cstdio and stdio.h

Status
Not open for further replies.

isaisa

Programmer
May 14, 2002
97
0
0
IN
hi all
i was going through C++ programming language -Stroustrup. I am confused in the header files that are mentioned for C linkage and normal stdio.h files.
The documentation says the following.


Code:
   //cstdio
    
   namespace std {
         void printf(const char*,...);
         /*Std C function declaration here */
   }

   //stdio.h

   #include <cstdio>
   using namespace std;


i am not getting the purpose and difference between the two header files. Can anybody help me in understanding ?

Further reading was related to the extern "C" directive in the same book. I am not able to understand the same , if anybody can help me.

thanks in advance
sanjay
 
They're exactly the same, except in <cstdio> (or <cstdlib>, <cmath>...) all the functions that were in the global namespace are now in the std namespace. The purpose of which is to reduce the possibility of namespace conflicts.

So if you include <stdio.h>, you just need to call: printf("...");
but if you include <cstdio>, you need to call: std::printf("...");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top