What is that to begin with:
std::string line =('8101001033900039','00','22','','','','','3','','0');
The compiler should give you something like that:
prog.cc:8:24: warning: character constant too long for its type
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~~~~~~~~~~~~~~~~
prog.cc:8:43: warning: multi-character character constant [-Wmultichar]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~~
prog.cc:8:48: warning: multi-character character constant [-Wmultichar]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~~
prog.cc:8:53: error: empty character constant
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:56: error: empty character constant
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:59: error: empty character constant
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:62: error: empty character constant
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:69: error: empty character constant
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc: In function 'int main()':
prog.cc:8:43: warning: left operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~~
prog.cc:8:48: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~~
prog.cc:8:53: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:56: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:59: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:62: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:65: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~
prog.cc:8:69: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~
prog.cc:8:72: warning: right operand of comma operator has no effect [-Wunused-value]
std::string line =('8101001033900039','00','22','','','','','3','','0');
^~~
prog.cc:8:71: error: conversion from 'char' to non-scalar type 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} requested
std::string line =('8101001033900039','00','22','','','','','3','','0');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
so the data themselves are not OK.
So now, let's replace single quotes with double quotes, since you probably want strings, like this:
std::string line =("8101001033900039","00","22","","","","","3","","0");
then only the right most operand will be assigned to line
, meaning that line
is now equal to "0"
. Read more about it in What does i = (i, ++i, 1) + 1; do?
EDIT:
You need this:
#include <fstream>
#include <string>
#include <iostream>
int main(void) {
std::string fileName = "output.txt";
std::string line ="('8101001033900039','00','22','','','','','3','','0'),";
std::ofstream out(fileName.c_str());
out << line << std::endl;
out.close();
return 0;
}