I've just gotten started on this and haven't gotten to the juicy parts yet but thought I'd just share some simple starting blocks to begin with (they'll be presuppositions for the complicated stuff anyway). The program compiles and works so far, and I just wondered what you guys think.
Here's my file htmltrans.h:
Code:
#ifndef HTMLTRANS_H
#define HTMLTRANS_H
std::string pathNames(std::string & sourcePath);
#endif
I'm gathering that some want #include <iostream> or #include <string> or both in this file, although it works as is.
Here's htmltrans.cpp:
Code:
#include <iostream>
#include <string>
#include "htmltrans.h"
std::string pathNames(std::string & sourcePath)
{
using namespace std;
string sourceFile, transPath;
char conf;
cout << "This program creates a copy of your source file\n"
<< "which will allow you to display code on the web.\n"
<< "Simply paste the text of the new file into your html file\n"
<< "in order to display the original coded text.\n\n";
cout << "You must first copy of the file you want to translate\n"
<< "into the directory c:\\html_trans\\\n"
<< "Press 'C' if you have completed this step\n"
<< "or any other key to end the program: ";
cin >> conf;
if (conf != 'c' && conf != 'C')
return "exit";
cout << endl;
cout << "Enter the name of the file you want to translate: ";
cin >> sourceFile;
sourcePath.append(sourceFile);
transPath = sourcePath;
int dot = transPath.find('.', 0), nameEnd = transPath.size();
int toErase = nameEnd - dot;
transPath.erase(dot, toErase); //chops off file extension
transPath.append("_wtrans.txt"); //adds recognizable new extension
return transPath;
}
And finally htmltrans_main.cpp:
Code:
#include <iostream>
#include <string>
#include <fstream>
#include "htmltrans.h"
int main()
{
using namespace std;
string sourcePath = "c:\\html_trans\\";
string transPath = pathNames(sourcePath);
if (transPath.at(0) != 'c')
return 0;
cout << "Here's the new path back in main:\n" << transPath << endl;
cout << "Here's the source path in main:\n" << sourcePath << endl;
return 0;
}