I am making an application that compresses CSS/HTML/JS Files by removing white space and other things but in the section that removes whitespace whenever a newline is encountered a equal sign is added.
Here is a slightly modified version of the class regarding whitespace.
Note: somethings like the test.txt instead of a variable are there for testing and debugging purposes, because I don't know how to make Visual Studio use the txt file inside the debugging directory during debugging
string minimize::open(/*char &file*/)
{
//Open File
fstream code ("new.txt", fstream::in | fstream::out);
//Alocate Memory
int length = 0;
//Get Length of File
code.seekg (0, ios::end);
length = code.tellg();
//Move Buffer back to beggining of file for opperations
code.seekg (0, ios::beg);
//Allocate Memory
char* content = newchar [length];
//Move content to array if buffer is still available
if (code.good())
{
code.read(content,length);
}
else
{
cout << "Failure";
}
/*Move Content From Memory to Local Variables
Then Close The File*/
code.write(content, length);
code.close();
string pre_process;
cout << pre_process;
for (int i = 0; i < length; i++)
{
pre_process += content [i];
}
//Free Memory
delete content;
return pre_process;
}
ouput when given hi followed by a new line is
1 2
hi
=
I am Using Visual Studio 2012 RC. Please Help me please i recently finished Accelerated C++ so I know most of the STL (they skipped alot of information on fstream).