I am trying to find a bug in my new and (theoretically) improved syntax highlighter program. I have made 3 versions now and have been able to debug them all with ease. Unfortunately my debugger does not do well with std containers as it shows ALL the information they contain and it can be hard to sift through it to find errors. Can anybody see where I went wrong in this code?
evenBetterMain.cpp: (since I already have main.cpp and betterMain.cpp working :P)
#include <iostream> //for cin/cout
#include <string> //for std::strings, obviously
#include <fstream> //for file operations
#include <stdio.h> //for integer parsing
using namespace std;
string readFile(string fileName)
{
fstream file(fileName.c_str()); //open the file
if (!file.is_open()) //check that it opened
return "";
string ret=""; //initialize the return value
while (!file.eof()) //loop through the whole file
ret+=file.get(); //grab a character and append it to the return value
file.close(); //close the file
return ret;
}
void writeFile(string fileName, string text)
{
fstream file(fileName.c_str()); //open the file
if (!file.is_open()) //check that it opened
return;
file<<text; //write the text
file.close(); //close the file
}
struct highlightFormatter
{
string start; //this is written at the start of the information
string end; //this is written at the end of the information
string newLine; //this is written at the end of each line of the information
string code; //this is written at the start of a segment labeled as code
string comment; //this is written at the start of a segment labeled as comment
string documentation; …