如何将C ++代码更改为C? [英] How do I change code of C++ to C?
问题描述
我在c ++中有一个代码,它具有像c中所有的编码,例如的printf / scanf函数。但它也有fstream.h库。如何将这些代码更改为C编程?
我尝试过:
我尝试删除fstream.h库但收到了n个错误。
I have a code in c++ which has all coding like in c e.g. printf/scanf. But it also has library of fstream.h . How to change such codes to C programming?
What I have tried:
I have tried removing fstream.h library but received n number of errors.
推荐答案
重写它以使用C库函数而不是C ++。
Rewrite it to use C library functions instead of C++.
但它也有fstream.h的库。如何将此类代码更改为C编程
But it also has library of fstream.h . How to change such codes to C programming
您必须使用 fprintf,fwrite,fread
而不是相应的 fstream
方法和运算符(参见 fstream - C ++参考a> [ ^ ])。由于代码包含 C
-like函数,用于控制台 I / O
,可能没有太多使用插入和提取操作员和你的任务相对简单。
You have to use fprintf, fwrite, fread
instead of corresponding fstream
methods and operators (see fstream - C++ Reference[^] ). Since the code contains C
-like function for console I/O
, probably there is no much use of insertion and extraction operators and your task is relatively simple.
这篇关于如何将C ++代码更改为C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!