The combined usage of C and C++ in a program system is subject to the following restrictions:
Free store management
The
newanddeleteoperators in C++ provide a separate facility for free store management. Storage space management in C, by contrast, is achieved by the functionsmallocandfree. These two methods must not be combined.The effect of using
deleteto free storage that was requested withmalloc(or usingfreeon storage that was requested withnew) is undefined.Standard I/O files
C++ offers a new interface for file processing. The C++ standard files
cin,cout,cerrandclogcorrespond to the standard I/O filesstdin,stdoutandstderrin C.Note that if the corresponding standard files are used in both C and C++, the behavior of the program cannot be guaranteed.
If the standard I/O files for C and C++ are to be used in combination in the same C++ program, the C++ function
ios::sync_with_stdio()must be called (see the manual “C++ Library Functions” [5]).