P
Pieter Provoost
Hi,
I just made my first c++ program, and I would like to know if there are
things I can do better. Also, the exe is about 500 kb, can I make it
smaller?
Thanks!
Pieter
#include <string>
#include <fstream>
using namespace std;
int main()
{
string buffer;
string includebuffer;
string bestand;
string configin;
string configout;
ifstream config("config.txt");
getline(config, configin);
getline(config, configout);
config.close();
ifstream infile(configin.c_str());
ofstream outfile(configout.c_str());
while (getline(infile, buffer))
{
if (buffer == "")
{
outfile << " " << endl;
}
else
{
if (buffer.substr(1,7) == "include")
{
bestand = buffer.substr(9, (buffer.find_first_of("}") - 9));
bestand += ".tex";
ifstream includefile(bestand.c_str());
while (getline(includefile, includebuffer))
{
outfile << includebuffer << endl;
}
includefile.close();
}
else
{
outfile << buffer << endl;
}
}
}
infile.close();
outfile.close();
return 0;
}
I just made my first c++ program, and I would like to know if there are
things I can do better. Also, the exe is about 500 kb, can I make it
smaller?
Thanks!
Pieter
#include <string>
#include <fstream>
using namespace std;
int main()
{
string buffer;
string includebuffer;
string bestand;
string configin;
string configout;
ifstream config("config.txt");
getline(config, configin);
getline(config, configout);
config.close();
ifstream infile(configin.c_str());
ofstream outfile(configout.c_str());
while (getline(infile, buffer))
{
if (buffer == "")
{
outfile << " " << endl;
}
else
{
if (buffer.substr(1,7) == "include")
{
bestand = buffer.substr(9, (buffer.find_first_of("}") - 9));
bestand += ".tex";
ifstream includefile(bestand.c_str());
while (getline(includefile, includebuffer))
{
outfile << includebuffer << endl;
}
includefile.close();
}
else
{
outfile << buffer << endl;
}
}
}
infile.close();
outfile.close();
return 0;
}