C++ ubuntu13.10中的GCC iostream fstream错误

C++ ubuntu13.10中的GCC iostream fstream错误,c++,c,ubuntu,gcc,C++,C,Ubuntu,Gcc,我正在使用Ubuntu 13.10。我得到以下代码的一些错误 #include <stdlib.h> #include <stdio.h> #include <fstream.h> int main(int argc, char *argv[]) { error.set_program_name(argv[0]); if ( argc != 2 ) { // printf(argv[0] + " usage: fi

我正在使用Ubuntu 13.10。我得到以下代码的一些错误

#include <stdlib.h>
#include <stdio.h>
#include <fstream.h>

int main(int argc, char *argv[])
{
    error.set_program_name(argv[0]);    

    if ( argc != 2 )
    {
    //  printf(argv[0] + " usage: fifo_client [string] \n");
    /// cout << argv[0] << " usage: fifo_client [string]" << endl;
        exit(EXIT_FAILURE);
    }

    ofstream out(fifo_file);
    if(out)

        out << argv[1] << endl;

    return(EXIT_SUCCESS);
}
#包括
#包括
#包括
int main(int argc,char*argv[])
{
错误。设置程序名称(argv[0]);
如果(argc!=2)
{
//printf(argv[0]+“用法:fifo_客户端[字符串]\n”);

//couth问题是,你使用GCC混合C+C++代码并编译它。问题是你在使用C++和C++混合GC++C++代码,编译它。使用G+代替GCC。如果它有正确的扩展(例如CPP)或正确的参数(Google+C++<代码>),GCC可以编译C++文件。但是添加与C++库链接所需的参数太复杂,无法避免简单的解决方案。

< P>使用G++代替GCC。如果它有正确的扩展(例如CPP)或正确的参数(Google>C++-XC++,代码>),GCC可以编译C++文件。但是添加与C++库链接所需的参数太复杂,无法避免简单的解决方案。

< P>尝试

#include <fstream>
using namespace std;
#包括
使用名称空间std;
代替
#包括

无论如何,您的源代码不完整,无法提供正确的建议。

试试看

#include <fstream>
using namespace std;
#包括
使用名称空间std;
代替
#包括


无论如何,您的源代码不完整,无法提供正确的建议。

我在编译器中运行了您的代码,并出现以下错误:-

test2.c:3:21: fatal error: fstream.h: No such file or directory
 #include <fstream.h>
                     ^
compilation terminated.
test2.c:3:21:致命错误:fstream.h:没有这样的文件或目录
#包括
^
编译终止。
所以我认为你的问题有错


因为你是混合C和C++代码,fStand是C++的一部分。尝试用G++运行。< /P> < P>我在编译器中运行你的代码,并得到以下错误:-< /P>

test2.c:3:21: fatal error: fstream.h: No such file or directory
 #include <fstream.h>
                     ^
compilation terminated.
test2.c:3:21:致命错误:fstream.h:没有这样的文件或目录
#包括
^
编译终止。
所以我认为你的问题有错


因为你是混合C和C++代码,fStand是C++的一部分。尝试用g++。< /p>重命名为<代码> .aCPP < /C> >,使用<代码> G++< /C>命令。