Category : ofstream

I tried to write my own method to save a Eigen::MatrixXd object in a textfile. However, the file is empty after running this method. While debugging, I saw that the file does not open as I want. Can anyone tell me why? #include<EigenDense> #include<iostream> #include<fstream> #include<string> using namespace std; void savematrix(Eigen::MatrixXd matrix, string filename) { ..

Read more

I’ve written the rather simple program below, which is designed to read a file of directories line by line, determine if they simultaneously contain two strings and, if so, write the directory to another file. It throws the following error: error: cannot initialize an array element of type ‘void *’ with an rvalue of type ..

Read more

my code ofstream fout("output.txt"); class Cards{ public: char suit; int number; int visibilty; public: Cards(){ number=0; suit=’A’; visibilty=0; }; Cards(char suitName, int suitNumber, int cardVisibility){ suit=suitName; number=suitNumber; visibilty=cardVisibility; } //class function virtual void printIt(){ if(number<10&&visibilty==1&&suit!=’A’) fout << Cards::suit << 0<<Cards::number; else if(number>=10&&visibilty==1&&suit!=’A’){ fout << Cards::suit << Cards::number; } else if(suit==’A’){ } else fout<<"@@@"; } //creating ..

Read more

am new in Qt and trying to write my program from VS (MVCS) for Qt(MinGb) I am using ofstream and has a folowing code: #include <fstream> #include <string> #include <iostream> #include <exception> using namespace std; void WriteToFile(ofstream* fileToWrite, std::string StringNeedsToWrite) { if (fileToWrite) { if (IsStartOfNewString(StringNeedsToWrite)) { *fileToWrite << ‘n’; } *fileToWrite << StringNeedsToWrite; } ..

Read more