Hey guys. Its been a few months since i worked in console with the fstream functions and im doing something wrong. I'm missing something and i know its gotta be something stupid, but im wrong none the less. The program is new i just started it, the problem is in loading the txt file. The comments in the beginning explain the idea behind the program, and the output is at the bottom commented off.
I tried using another text file named test.txt that said "Hello im a test" and got jibberish also, but in the right amount of characters. Attached is the text file im using. Follow the commented instructions and place the txt accordingly. Many of u will probably be able to look at just the code and know what im missing.
Sorry for the lame problem.
Code:
/* Steven Billington
[email protected]
August 15, 2003
Program is used to check for valid entries in any Half-Life
mapcycle.txt. Create a folder on your c:\ drive named Mapfiles
and inside make a folder named Maps. Pick the mod you wish to
test and paste its .bsp files into the Maps folder, and paste its
mapcycle.txt into the main Mapfiles folder. The program will scan
the Maps folder and mapcycle.txt and ensure no maps are in the cycle
that arent in the maps folder. If it finds invalid entries it will
remove them and store the removed entries into a log file in the
Mapfiles directory.
*/
/* Preprocessor Directives
*/
#include "stdafx.h"
#include <iostream>
#include <fstream>
/* Declare use of the standard
namepsace
*/
using namespace std;
/* Class: MAIN
Descr: Contains the functions and variables
for use in the program. On a larger scale
there would be several classes, were only
using one.
Function: mapcycle
Purpose: Used to load the mapcycle text file.
Function: Compare
Purpose: This function is used to compare the contents
of the Half-Life map folder against the mapcycle.txt
to ensure all entried are valid.
*/
class MAIN
{
public:
void MAIN_openmapcycle();
void MAIN_Compare();
ifstream mapcyclein;
ofstream mapcycleout;
char fromFile;
};
/* The function main defines the entry point
for the application
*/
int _tmain(int argc, _TCHAR* argv[])
{
/* To access the members of the class
MAIN we need to declare an object of
type MAIN
*/
MAIN MainObj;
/* Call member functions
*/
MainObj.MAIN_openmapcycle();
/* Always return a value
*/
return 0;
}
/* Function mapcycle is a member function
of class MAIN
*/
void MAIN::MAIN_openmapcycle()
{
mapcyclein.open("c:\\Mapfiles\\mapcycle.txt");
if (mapcyclein.fail())
{
cout << "FATAL: Failed to MAIN mapcycle.txt!"
<< endl;
}
mapcyclein.get(fromFile);
while (!mapcyclein.eof())
{
cout << mapcyclein << endl;
mapcyclein.get(fromFile);
}
}
/*
Output
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
0012FDFC
Press any key to continue
*/