My entrada.txt jas the following contents:
#Commented text
#This should be used like:
#Bar:Bar_number:Type_of_the_bar;
#
#
Bar:1:PV:1.05
So the lines that starts with # are commented so the program will not process them. Everything is working fine, but when I used getline() to delimit the string on ":" it gives the error above, saying that getline only accept 2 instead of 3 arguments?
#include "stdafx.h"
#include <fstream>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
//using namespace std;
using std::ifstream;
int _tmain(int argc, _TCHAR* argv[])
{
//
std::ifstream arquivo("entrada.txt");
if (!arquivo)
{
std::cout << "File not found" << std::endl<< std::endl;
system("PAUSE");
exit(0);
}
else
{
std::cout << "Loading file...Please wait..." << std::endl << std::endl;
}
//fim do carregamento
//declarações das strings
std::string token,arq_linha_part;
char arquivo_linha[255];
while(arquivo)
{
arquivo.getline(arquivo_linha,255);
if (arquivo_linha[0] != 35)
{
token = arquivo_linha;
while(std::getline(token,arq_linha_part,":"))
{
std::cout << arq_linha_part << std::endl;
}
}
}
system("PAUSE");
return 0;
}
error:
1>------ Build started: Project: Interface GaussSolve, Configuration: Debug Win32 ------
1>Compiling...
1>Interface GaussSolve.cpp
1>c:\users\fernando\documents\visual studio 2008\projects\interface gausssolve\interface gausssolve\interface gausssolve.cpp(39) : error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : expects 2 arguments - 3 provided
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(527) : see declaration of 'std::getline'
1>c:\users\fernando\documents\visual studio 2008\projects\interface gausssolve\interface gausssolve\interface gausssolve.cpp(39) : error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::string'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(475) : see declaration of 'std::getline'
1>c:\users\fernando\documents\visual studio 2008\projects\interface gausssolve\interface gausssolve\interface gausssolve.cpp(39) : error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::string'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(475) : see declaration of 'std::getline'
1>c:\users\fernando\documents\visual studio 2008\projects\interface gausssolve\interface gausssolve\interface gausssolve.cpp(39) : error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::string'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(475) : see declaration of 'std::getline'
1>c:\users\fernando\documents\visual studio 2008\projects\interface gausssolve\interface gausssolve\interface gausssolve.cpp(39) : error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::string'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(475) : see declaration of 'std::getline'
1>c:\users\fernando\documents\visual studio 2008\projects\interface gausssolve\interface gausssolve\interface gausssolve.cpp(39) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://c:\Users\Fernando\Documents\Visual Studio 2008\Projects\Interface GaussSolve\Interface GaussSolve\Debug\BuildLog.htm"
1>Interface GaussSolve - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========