Can't compile this small code on Linux:
#include <fstream>
#include <string>
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
char fileName[512];
sprintf(fileName, "test");
ofstream iriFile(string(fileName));
iriFile<<",";
return 0;
}
I am compiling like this: g++ test.cpp and am getting this:
test.cpp:12:11: error: invalid operands of types ‘std::ofstream(std::__cxx11::string) {aka std::basic_ofstream(std::__cxx11::basic_string)}’ and ‘const char [2]’ to binary ‘operator<<’ iriFile<<",";
What might be the reason?