delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/07/15/08:16:14

Date: Fri, 15 Jul 1994 13:24:36 +0300
From: a DOT j DOT krijgsman AT ET DOT TUDelft DOT NL (Ardjan Krijgsman)
Subject: Bug in IOSTREAM?
To: djgpp AT sun DOT soe DOT clarkson DOT edu

I am using the DJGPP installation on my 486-66 machine. I am writing some
software in C++. I detected some strange problem using the library of C++ for
I/O. It seems that appending some information to a file fails completely, and
leads to a crash of the program. The same program can be compiled on other
platforms (LINUX the same type of machine) and runs perfectly........... 
Can anybody give me a hint what is
the matter with my installation of DJGPP, or is it a bug?




PROGRAM:

#include    <stdlib.h>
#include	<stdio.h>
#include	<math.h>
#include	<fstream.h>
#include	<string.h>


void    writeToFile(char filename[], int teller)
{
    fstream stream(filename, ios::app);      // ****** This gives the 
problem ******
    stream << '\n'  << "iter = " << teller ;
    stream.close();
}

int main(int argc, char *argv[])
{
	char  filename[13];
	int i;

                    if (argc < 2)
	{
	   cerr << "Not enough arguments: give a filename";
	   exit(1);
	}
	strcpy(filename,argv[1]);
	
	fstream stream(filename, ios::out);
	stream << '\n' << "Filename: " << filename << '\n';
	stream.close();
                    for (i=0; i<10; i++)  writeToFile(filename, i);
                    return (0);
}


I have checked the program with the GNU debugger, and this program reports a 
crash in the  the:

    filebuf::open


Looking forward to get an answer to my problem!




Ardjan Krijgsman
Delft University of Technology
Department of Electrical Engineering
Control Laboratory
P.O. Box 5031
2600 GA  Delft
The Netherlands

Phone: +31 15 785114
Fax: +31 15 626738
Email: a DOT j DOT krijgsman AT et DOT tudelft DOT nl





----------------------------------------------------------------------------
---------------------------------

Dr. ir. Ardjan  Krijgsman
Control Laboratory
Department of Electrical Engineering
Delft University of Technology
P.O. Box 5031
2600 GA  Delft
The Netherlands

Phone: +31 15 785114
Fax:       +31 15 626738


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019