Thread: A runtime library error on this line???

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    44

    A runtime library error on this line???

    Hi,

    I've got the following code:

    Code:
    CString input;
    bool found = false;
    
    fstream myfile;
    myfile.open(filetoopen,ios::in);
    
    while(!myfile.eof()){
    	myfile.getline(input.GetBuffer(250),249,"\n");
    	input.ReleaseBuffer();
    	found=false;
    
    	for(int i=0;i<filebuffer.GetSize();i++){
    		if(filebuffer.GetAt(i)==input){
    			found=true;
    			break;
    		}
    	}
    	if(found)
    		linecnt.assign(i,(linecnt.at(i)+=1));
    	else{
    						
    		filebuffer.Add(input); //THIS LINE CAUSES THE ERROR APPARENTLY?
    
    		linecnt.push_back(1);
    	}
    }

    I've found the line causing the problem simply by commenting out certain chunks until I've got it down to that. Although I REALLY can't see why this could cause a problem in the slightest! Any help would be appreciated...

    Thanks!

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What is fileBuffer declared as?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    44
    CStringArray...also:

    vector <int> linecnt;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. adding line numbers and concatenating a filename
    By durrty in forum C Programming
    Replies: 25
    Last Post: 06-28-2008, 03:36 AM
  2. link with C runtime library
    By George2 in forum C++ Programming
    Replies: 26
    Last Post: 02-05-2008, 01:56 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. Trouble replacing line of file
    By Rpog in forum C Programming
    Replies: 4
    Last Post: 04-19-2004, 10:22 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM