So, you want to print out a file, but when you come across a dollar sign, what do you want to happen? You want to print the file with the name of the character after it?
So '1 2 3 $ P 4 5 6' would print 1 2 3, then the contents of P.txt, then 4 5 6?
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
unsignedchar index; // takes up less memory than int, and still lets you
// recurse up to 256 files :)
fstream files[256];
files[0].open("c:\\F.txt", ios::in);
index++;
char buffer;
do {
files[index] >> buffer;
if (files[index].eof()) {
index--;
if (index == 0) break;
continue;
}
elseif (buffer == '$') {
files[index] >> buffer >> buffer; // eat a byte, then get the next
// UNFORTUNATELY< I SUCK AT C++ TOO MUCH TO OPEN THE FILE.
// I HATE YOU ALL.
files[index].open(/* SHIT GOES HERE */, ios::in);
index++;
}
cout << buffer << endl;
} while(true);
}