(国际&)' ReadClientFile.cpp:(.text+0x3d5):对“std::basic\u istream&std::operator>>(std::basic\u istream&,char*)”的未定义引用 ReadClientFile.cpp:(.text+0x3e9):对“std::basic\u istream::operator>>(double&)”的未定义引用 ReadClientFile.cpp:(.text+0x3fd):对“std::basic_ios::operator void*()const”的未定义引用 ReadClientFile.cpp:(.text+0x41d):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 ReadClientFile.cpp:(.text+0x453):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 /tmp/ccVkuUp1.o:(.eh_frame+0x12):未定义对“\uuuugxx\u personality\uv0”的引用 collect2:ld返回了1个退出状态,c++,gcc,file-io,C++,Gcc,File Io" /> (国际&)' ReadClientFile.cpp:(.text+0x3d5):对“std::basic\u istream&std::operator>>(std::basic\u istream&,char*)”的未定义引用 ReadClientFile.cpp:(.text+0x3e9):对“std::basic\u istream::operator>>(double&)”的未定义引用 ReadClientFile.cpp:(.text+0x3fd):对“std::basic_ios::operator void*()const”的未定义引用 ReadClientFile.cpp:(.text+0x41d):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 ReadClientFile.cpp:(.text+0x453):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 /tmp/ccVkuUp1.o:(.eh_frame+0x12):未定义对“\uuuugxx\u personality\uv0”的引用 collect2:ld返回了1个退出状态,c++,gcc,file-io,C++,Gcc,File Io" />

读取C+中的顺序文件时出错+; 当我尝试编译我的C++样本时,我遇到了一些问题,我正在尝试读取一个序列文件,但是当我编译时,我得到了一些错误,这里是代码: // ReadClientFile.cpp // Lendo e imprimindo um arquivo sequêncial. #include <iostream> using std::cerr; using std::cout; using std::endl; using std::fixed; using std::ios; using std::left; using std::right; using std::showpoint; #include <fstream> // Fluxo de arquivo using std::ifstream; // Insere fluxo de arquivo #include <iomanip> using std::setw; using std::setprecision; #include <string> using std::string; #include <cstdlib> using std::exit; // Sai do protótipo de funcão void outputLine( int, const string, double ); // Protótipo int main() { // Construtor ifstream, abre o arquivo ifstream inClientFile( "Clients.dat", ios::in ); // Fecha o programa se ifstream não pode abrir o arquivo if ( !inClientFile ) { cerr << "File could not be opened" << endl; exit ( 1 ); } // Fim do if int account; char name[ 30 ]; double balance; cout << left << setw( 10 ) << "Account" << setw( 13 ) << "Name" << "Balance" << endl << fixed << showpoint; // Exibe cada registro do arquivo while ( inClientFile >> account >> name >> balance ) outputLine( account, name, balance ); return 0; // Destrutor ifstream fecha o arquivo } // Fim de main // Exibe um registro do arquivo void outputLine( int account, const string name, double balance ) { cout << left << setw( 10 ) << account << setw( 13 ) << name << setw( 7 ) << setprecision( 2 ) << right << balance << endl; } // Fim da funcão outputLine //ReadClientFile.cpp //这是一个很好的例子。 #包括 使用std::cerr; 使用std::cout; 使用std::endl; 使用std::fixed; 使用std::ios; 使用std::left; 使用std::right; 使用std::showpoint; #包括//Fluxo de arquivo 使用std::ifstream;//阿奎沃fluxo插图 #包括 使用std::setw; 使用std::setprecision; #包括 使用std::string; #包括 使用std::exit;//西多·普罗蒂波·德·芬科(Sai do protótipo de funcão) void outputLine(int,常量字符串,双精度);//普罗托蒂波酒店 int main() { //施工方ifstream,abre o arquivo ifstream inClientFile(“Clients.dat”,ios::in); //在阿奎沃河上游的一个项目 如果(!inClientFile) { cerr>(国际&)' ReadClientFile.cpp:(.text+0x3d5):对“std::basic\u istream&std::operator>>(std::basic\u istream&,char*)”的未定义引用 ReadClientFile.cpp:(.text+0x3e9):对“std::basic\u istream::operator>>(double&)”的未定义引用 ReadClientFile.cpp:(.text+0x3fd):对“std::basic_ios::operator void*()const”的未定义引用 ReadClientFile.cpp:(.text+0x41d):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 ReadClientFile.cpp:(.text+0x453):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 /tmp/ccVkuUp1.o:(.eh_frame+0x12):未定义对“\uuuugxx\u personality\uv0”的引用 collect2:ld返回了1个退出状态

读取C+中的顺序文件时出错+; 当我尝试编译我的C++样本时,我遇到了一些问题,我正在尝试读取一个序列文件,但是当我编译时,我得到了一些错误,这里是代码: // ReadClientFile.cpp // Lendo e imprimindo um arquivo sequêncial. #include <iostream> using std::cerr; using std::cout; using std::endl; using std::fixed; using std::ios; using std::left; using std::right; using std::showpoint; #include <fstream> // Fluxo de arquivo using std::ifstream; // Insere fluxo de arquivo #include <iomanip> using std::setw; using std::setprecision; #include <string> using std::string; #include <cstdlib> using std::exit; // Sai do protótipo de funcão void outputLine( int, const string, double ); // Protótipo int main() { // Construtor ifstream, abre o arquivo ifstream inClientFile( "Clients.dat", ios::in ); // Fecha o programa se ifstream não pode abrir o arquivo if ( !inClientFile ) { cerr << "File could not be opened" << endl; exit ( 1 ); } // Fim do if int account; char name[ 30 ]; double balance; cout << left << setw( 10 ) << "Account" << setw( 13 ) << "Name" << "Balance" << endl << fixed << showpoint; // Exibe cada registro do arquivo while ( inClientFile >> account >> name >> balance ) outputLine( account, name, balance ); return 0; // Destrutor ifstream fecha o arquivo } // Fim de main // Exibe um registro do arquivo void outputLine( int account, const string name, double balance ) { cout << left << setw( 10 ) << account << setw( 13 ) << name << setw( 7 ) << setprecision( 2 ) << right << balance << endl; } // Fim da funcão outputLine //ReadClientFile.cpp //这是一个很好的例子。 #包括 使用std::cerr; 使用std::cout; 使用std::endl; 使用std::fixed; 使用std::ios; 使用std::left; 使用std::right; 使用std::showpoint; #包括//Fluxo de arquivo 使用std::ifstream;//阿奎沃fluxo插图 #包括 使用std::setw; 使用std::setprecision; #包括 使用std::string; #包括 使用std::exit;//西多·普罗蒂波·德·芬科(Sai do protótipo de funcão) void outputLine(int,常量字符串,双精度);//普罗托蒂波酒店 int main() { //施工方ifstream,abre o arquivo ifstream inClientFile(“Clients.dat”,ios::in); //在阿奎沃河上游的一个项目 如果(!inClientFile) { cerr>(国际&)' ReadClientFile.cpp:(.text+0x3d5):对“std::basic\u istream&std::operator>>(std::basic\u istream&,char*)”的未定义引用 ReadClientFile.cpp:(.text+0x3e9):对“std::basic\u istream::operator>>(double&)”的未定义引用 ReadClientFile.cpp:(.text+0x3fd):对“std::basic_ios::operator void*()const”的未定义引用 ReadClientFile.cpp:(.text+0x41d):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 ReadClientFile.cpp:(.text+0x453):对“std::basic\u ifstream::~basic\u ifstream()”的未定义引用 /tmp/ccVkuUp1.o:(.eh_frame+0x12):未定义对“\uuuugxx\u personality\uv0”的引用 collect2:ld返回了1个退出状态,c++,gcc,file-io,C++,Gcc,File Io,使用以下两种方法之一: g++ ReadClientFile.cpp 或 P>我猜GCC默认情况下不是连接到标准C++库。一般来说,你应该使用G++来编译C++程序。 < P>编译在GCC 4.3版本上没有任何错误的代码。但是它在一个文件中不工作,有一个以上的客户记录条目。它也会有包含空格的客户端名的问题。所以我做了一些。对代码的简单修改,使其能够与CSV一起工作 // ReadClientFile.cpp // Lendo e imprimindo um arquivo sequência

使用以下两种方法之一:

g++ ReadClientFile.cpp


<> P>我猜GCC默认情况下不是连接到标准C++库。一般来说,你应该使用G++来编译C++程序。

< P>编译在GCC 4.3版本上没有任何错误的代码。但是它在一个文件中不工作,有一个以上的客户记录条目。它也会有包含空格的客户端名的问题。所以我做了一些。对代码的简单修改,使其能够与CSV一起工作

// ReadClientFile.cpp
// Lendo e imprimindo um arquivo sequêncial.

#include <iostream>
#include <fstream> // Fluxo de arquivo
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;

static void outputLine(int, const string, 
               double); // Protótipo

int main()
{
  // Construtor ifstream, abre o arquivo
  ifstream inClientFile("Clients.dat", ios::in);

  // Fecha o programa se ifstream não pode abrir o arquivo
  if (!inClientFile)
    {
      cerr << "File could not be opened" << endl;
      return 1;
    } // Fim do if

  int account;
  string name;
  double balance;
  const int buffSize = 80;
  char* buffer = new char[buffSize + 1];

  cout << left << setw( 10 ) << "Account" << setw( 13 )
       << "Name" << "Balance" << endl << fixed << showpoint;

  // Exibe cada registro do arquivo
  while (!inClientFile.eof())
    {
      inClientFile.getline(buffer, buffSize, ',');
      account = atoi(buffer);
      inClientFile.getline(buffer, buffSize, ',');
      name = buffer;
      inClientFile.getline(buffer, buffSize, ',');
      balance = atof(buffer);
      outputLine(account, name, balance);
    }

  return 0; // Destrutor ifstream fecha o arquivo
} // Fim de main

// Exibe um registro do arquivo
void outputLine(int account, const string name, double balance)
{
  cout << left << setw( 10 ) << account << setw( 13 ) << name
       << setw( 7 ) << setprecision( 2 ) << right << balance << endl;
} // Fim da funcão outputLine 
//ReadClientFile.cpp
//这是一个很好的例子。
#包括
#包括//Fluxo de arquivo
#包括
#包括
#包括
使用名称空间std;
静态无效输出行(int,常量字符串,
double);//Protótipo
int main()
{
//施工方ifstream,abre o arquivo
ifstream inClientFile(“Clients.dat”,ios::in);
//在阿奎沃河上游的一个项目
如果(!inClientFile)
{
cerr不使用gcc(使用g++)。还有一些不一致的地方(我记不得了)。
gcc ReadClientFile.cpp -lstdc++
// ReadClientFile.cpp
// Lendo e imprimindo um arquivo sequêncial.

#include <iostream>
#include <fstream> // Fluxo de arquivo
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;

static void outputLine(int, const string, 
               double); // Protótipo

int main()
{
  // Construtor ifstream, abre o arquivo
  ifstream inClientFile("Clients.dat", ios::in);

  // Fecha o programa se ifstream não pode abrir o arquivo
  if (!inClientFile)
    {
      cerr << "File could not be opened" << endl;
      return 1;
    } // Fim do if

  int account;
  string name;
  double balance;
  const int buffSize = 80;
  char* buffer = new char[buffSize + 1];

  cout << left << setw( 10 ) << "Account" << setw( 13 )
       << "Name" << "Balance" << endl << fixed << showpoint;

  // Exibe cada registro do arquivo
  while (!inClientFile.eof())
    {
      inClientFile.getline(buffer, buffSize, ',');
      account = atoi(buffer);
      inClientFile.getline(buffer, buffSize, ',');
      name = buffer;
      inClientFile.getline(buffer, buffSize, ',');
      balance = atof(buffer);
      outputLine(account, name, balance);
    }

  return 0; // Destrutor ifstream fecha o arquivo
} // Fim de main

// Exibe um registro do arquivo
void outputLine(int account, const string name, double balance)
{
  cout << left << setw( 10 ) << account << setw( 13 ) << name
       << setw( 7 ) << setprecision( 2 ) << right << balance << endl;
} // Fim da funcão outputLine