Thread: Newbie Mistakes

  1. #1
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Newbie Mistakes

    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
    */

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Forgot the txt file:

  3. #3
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Thats what i get for rushing. Thank you.

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Just wondering, aren't you getting 1 character at a time and printing it out on a new line each time? Shouldn't you have a char array and then use getline() if you're going to be checking if each map is in the maps folder?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    yea ive changed it. I'm feeding it into a string till '\n' is met, then passing to a function to scan and moving on to the next line. im stuck but ima look at it tomorrow b4 i post again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. newbie needs help with C++ program
    By cyba in forum C++ Programming
    Replies: 9
    Last Post: 06-25-2004, 02:41 AM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM