R
Ram Laxman
Hi all,
The below code doesnot print the string reading from the file?
error C2679: binary '<<' : no operator defined which takes a
right-hand operand of type 'class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >' (or there is no
acceptable conversion)
Error executing cl.exe.
Does anybody know how to fix it.Iam using VC++ 6.0.
#include<fstream>
#include<ios>
#include <iostream.h>
#include<string>
#include<iomanip>
#include<sstream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include <fcntl.h>
#include <io.h>
#include <cstdlib>
#include <cstring>
const char *filename ="C:\\result.txt";
//std:stream &operator<<(std:stream &os, const mypair &p)
using namespace std;
int main()
{
string tok1;
int result;
string s1,s2("a");
vector<int> v1;
int status;
status = _open(filename,_O_RDONLY);
if(status == -1)
{
printf("Couldnot able to Open file ");
}
else
{
printf("Opening of file Successful");
}
ifstream ifs(filename); // Open for reading
ofstream out("C:\divert.txt"); // Open for writing
string s,line;
while(getline(ifs, s)) // Discards newline char
{
// cout << s ; // ... must add it back
s += line + "\n";
// printf("%s",s);
cout << s << endl;
}
The below code doesnot print the string reading from the file?
error C2679: binary '<<' : no operator defined which takes a
right-hand operand of type 'class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >' (or there is no
acceptable conversion)
Error executing cl.exe.
Does anybody know how to fix it.Iam using VC++ 6.0.
#include<fstream>
#include<ios>
#include <iostream.h>
#include<string>
#include<iomanip>
#include<sstream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include <fcntl.h>
#include <io.h>
#include <cstdlib>
#include <cstring>
const char *filename ="C:\\result.txt";
//std:stream &operator<<(std:stream &os, const mypair &p)
using namespace std;
int main()
{
string tok1;
int result;
string s1,s2("a");
vector<int> v1;
int status;
status = _open(filename,_O_RDONLY);
if(status == -1)
{
printf("Couldnot able to Open file ");
}
else
{
printf("Opening of file Successful");
}
ifstream ifs(filename); // Open for reading
ofstream out("C:\divert.txt"); // Open for writing
string s,line;
while(getline(ifs, s)) // Discards newline char
{
// cout << s ; // ... must add it back
s += line + "\n";
// printf("%s",s);
cout << s << endl;
}