Thread: Having trouble with file input...

  1. #1
    Registered User
    Join Date
    Dec 2002

    Unhappy Having trouble with file input...

    Well folks, here's the deal: this script was working perfectly fine, peachy, whatever, but then I apparently did something to screw it up. Danged if I know what it was. *scratches head*


    [old]Note: readcon is a private ofstream of config, and writecon is a private ifstream[/old]
    [edit]Note: readcon is a private ifstream of config, and writecon is a private ofstream[/edit]
    config::loadconf( void ) {"config.blh");
    	if (!readcon) {cout << "Drat."<<endl;}
    	readcon >> temp;
    	if(!strcmp(temp,"JEPD")) {
    		readcon >> ver;
    	} else {
                    //Other stuff here, but wasn't running anyways, so doesn't matter.
    	return ver;
    int main ( void ) { //t'was more to my main, as well, but this is the stuff related to my prob...
    	config c;
    	return 0;	
    Now... inside config.blh is simple, plain ascii text of

    And, by the way, I didn't put that there, it was written with:
    config::newConf( void ) {"config.blh",ios::trunc);
    	writecon << "JEPD\n1\n[DBP]\n[ENDDBP]";
    	cout << "Created new config file.\n";"config.blh");
    	return 0;
    So, what happens is that it keeps running newConf...(and outputting "Drat").
    It never successfully opens the file to read from.

    I assume it's some easy fix that I'm missing, but I can't tell you what it is. Hopefully one of you can, I'll be greatfull for the help.

    If you need any additional info to help me with this, please ask, because I'm pretty screwed, right now.
    Last edited by Xaviar; 12-10-2002 at 12:59 PM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    I think you mean that readcon is an ifstream, and writecon is an ofstream.

  3. #3
    Registered User
    Join Date
    Dec 2002
    And you would be correct X_X


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. fscanf in different functions for the same file
    By bchan90 in forum C Programming
    Replies: 5
    Last Post: 12-03-2008, 09:31 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM