first program evaluation

From: Pieter Provoost (pieterprovoost_at_tiscali.be)
Date: 05/31/04


Date: Mon, 31 May 2004 19:39:06 +0200

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;
}



Relevant Pages

  • Re: first program evaluation
    ... The good news is as your program gets ... Don't use 'using namespace'. ... > string includebuffer; ...
    (comp.lang.cpp)
  • Re: Shell Functions and DOS executables
    ... Before you relocate the exe because of the short file name limitation of the ... ByVal lpszShortPath As String, _ ... Dim sShortPath As String ... Reports "Error Converting filename.wfm" if NOT successful ...
    (microsoft.public.vb.general.discussion)
  • Re: Working with a .exe file
    ... I think the trouble might be that Shell doesn't wait till the .exe is fully launched, ... lpReserved As String ... Private Declare Function WaitForSingleObject _ ... Dim lReturn As Long ...
    (microsoft.public.excel.programming)
  • RE: SoapHttpClientProtocol request canceled
    ... - VB.NET 2002 client dll that talks to the webservice. ... The VB.NET exe and the VB6 exe both use VB.NET dll to sent request/response ... > inputHeaderer, String messageControlPayload, string inputMessage) ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Creating Pre and Post build action add-in for VB6
    ... within the particular data string with your changes. ... I'd like to rename a previous existing exe to my.major.minor.revision.exe ... Is there a better way to determine the exe being built than looking for exe ... Dim sVersion As String ...
    (microsoft.public.vb.general.discussion)