H
Howard Kaikow
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:ut);
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;
}
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:ut);
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;
}