I was having difficulty trying to use ofstream in C++ 2003, so I booted to
another system that has VS C++ 6 and got the code working.
I then import the project into VS C++ .NET 2002. Code ran as expected. There
was a warning that the code was deprecated.
I then import the .NET 2002 project into C++ .NET 2003.
First, it stated that two libraries were not present.
So I removed the .h, the libraries were found, but htere were a whole lot of
errors ar build time.
What do I need to do to get the following running in C++ .NET 2003?
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <stdlib.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
char *buffer = "Bagels and lox";
ofstream outfile("stuff.dat", ios::out);
if (!outfile)
{
cerr << "Cannot open file";
exit(-1);
}
outfile << buffer << endl;
outfile.close();
ofstream bFile("binary.dat", ios::binary);
bFile.write(buffer, sizeof buffer);
bFile.close();
return 0;
}

Signature
http://www.standards.com/; See Howard Kaikow's web site.
Martin Richter [MVP] - 01 Jun 2005 12:01 GMT
Hallo Howard Kaikow!
> I then import the .NET 2002 project into C++ .NET 2003.
> First, it stated that two libraries were not present.
> So I removed the .h, the libraries were found, but htere were a whole lot of
> errors ar build time.
The STL is located in the namespace std!
> What do I need to do to get the following running in C++ .NET 2003?
>
> #include "stdafx.h"
> #include <iostream>
> #include <fstream>
> #include <stdlib.h>
// Insert this here
using namespace std;
> int APIENTRY WinMain(HINSTANCE hInstance,
> HINSTANCE hPrevInstance,
> LPSTR lpCmdLine,
[snip]

Signature
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
FAQ : http://www.mpdvc.de
Samples: http://www.codeguru.com http://www.codeproject.com
Howard Kaikow - 01 Jun 2005 12:43 GMT
> The STL is located in the namespace std!
> // Insert this here
> using namespace std;
Thanx.
Did MSFT ever explain why they deprecated/removed those libraries?
adebaene@club-internet.fr - 01 Jun 2005 13:02 GMT
Howard Kaikow a écrit :
> > The STL is located in the namespace std!
> > // Insert this here
[quoted text clipped - 3 lines]
>
> Did MSFT ever explain why they deprecated/removed those libraries?
I guess because the old iostream library :
- was non-standard and non-specified.
- was dangerously close to the new, standard iostream library (both
syntaxically and semantically), with just enough subtle differences to
make it easy to step on once foot when using one instead of the other.
- didn't provide any more capability than the new, standard one.
Arnaud
MVP - VC