I want to create a std::tuple
that contains int
, string
, string
, and bool
and save the information in a file. I cannot get the string elements. My code is the following
#include <tuple>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main ()
{
int a;
ofstream myfile;
myfile.open("lischen.txt");
tuple<int,string,strng,bool> tup (10,'lis','C:/',false);
a=get<0>(tup);
cout << "foo contains: ";
cout << std::get<0>(tup) << ' ';
myfile << "Writing this to a file.\n";
myfile << std::get<0>(tup) << ' ';
myfile << std::get<1>(tup) << ' ';
myfile << std::get<2>(tup) << ' ';
myfile << std::get<3>(tup) << ' ';
myfile.close();
return 0;
}
The error is the following 13 56 C:\Users\rafae\Desktop\lis.cpp [Error] invalid conversion from 'const char*' to 'char' [-fpermissive]
Aucun commentaire:
Enregistrer un commentaire