I misread the task you needed
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char **argv){
const int buff_size = 1024;
ofstream fout;
ifstream fin;
string input, delim;
char buff[buff_size];
if(argc < 4){
cout << "Usage: ./a.out <infile> <delimeter> <outfile>" << endl;
cout << "Enter input filename: "; cin >> input;
fin.open(input.c_str());
cout << "Enter output filename: "; cin >> input;
fout.open(input.c_str());
cout << "Enter delimeter: "; cin >> input;
delim.assign(input);
}else{
fin.open(argv[1]);
fout.open(argv[3]);
delim.assign(argv[2]);
cout << "Searching " << argv[1] << " for " << delim << endl;
cout << "Output directed to " << argv[3] << endl;
}
cout << endl;
while(!fin.eof()){
fin.getline(buff, (streamsize)buff_size);
input.assign(buff);
string::size_type index;
while((index = input.find(delim, 0)) != string::npos){
string rep;
cout << input << endl << "Enter string to replace " << delim << ": ";
cin >> rep;
input.erase(index, delim.length());
input.insert(index, rep);
input.append(1, 'n');
}
fout << input;
}
fin.close();
fout.close();
}
Give it as arguments an input file, the string that marks where you need something replaced (e.g. use XXXX everywhere there's an 'x' point), then the output file. If you give no arguments it prompts you for these.
When it comes upon an instance of XXXX (or whatever) it outputs the line and asks for what you want to replace it with.
Quote:
Originally Posted by Pooping^fish
It looks like what he posted is coming from linux, as a.out is the output of an unnamed compiled program. I wont take the time to write this (I dont think I could..) but itll have to consist of the program sifting through the text of your template files, searching for specified tags, and then inserting your data inbetween them. Sounds complicated.
I did however write a program a little bit back with the wonderful help of Hobo as usual and others here called Web Page Maker that will generate you a quick and simple html page.
You could possibly mess with that then migrate the other stuff from the templates if wanted. Not sure if thatll help at all.
|
OS X, but yeah - its UNIX

. a.out is the ouput that gcc (or g++ in this case) defaults to.