closed!

not question needed anymore
Last edited on
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?

You'll have to clarify.
!!fsf
Last edited on
Unfortunately, I suck at playing with strings. As such, I cannot complete this code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	unsigned char 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;
		}
		else if (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);
}


The code should be fully functional once you get the first argument to the files[index].open in the loop to be "c:\\" then the buffer then ".txt".
Last edited on
skfsfs
Last edited on
Topic archived. No new replies allowed.