Okay so I am making a small application to be used in large text files that have useless data. So all the data after the first space on each line gets deleted. i have worked all the compilation errors out except one. Here is the source.
// extract.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string x;
cout << "Enter file name" << endl;
cin >> x;
fstream file;
file.open(x.c_str()); // open file
if(file)
{
ofstream out("data.txt");
if(!out)
{
cout << "Cannot open or create file.";
return 2;
}
string s="";
char* lookfor = " ";
while(!file.eof())
{
while(getline(file,s))
{
if (lookfor != NULL)
{
out << s.peek;
}
}
}
}
else
{
cout << "Error opening file.";
return 1;
}
return 0;
}
Here is my error
1 2 3 4 5 6 7 8
error C2039: 'peek' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]