473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

header files in VC++.NET

I'm trying to learn VC++.NET. I used till now Borland C++ Builder 6.
I had a program starting like this:

#include <fstream.h>
#define TEMP_FILES 200
......
.......
fstream chunk_file[TEMP_FILES];

With Borland and g++ I had no problems with these lines instead VC++.NET
tells me that can't find #include <fstream.h>
I saw that it works with
#include <fstream> (without .h)
but if I use the header files this way I get an error in this declaration:

fstream chunk_file[TEMP_FILES];

So if I try to build this short program:
=========================================
#include "stdafx.h"
#include <fstream>
#define TEMP_FILES 200

int _tmain(int argc, _TCHAR* argv[])
{
fstream chunk_file[TEMP_FILES];
return 0;
}
================================================== ===

VC++ gives me these errors:

error C2065: 'fstream' : undeclared identifier
(in fatc it knows what fstream is: A type basic_fstream specialized on char
template parameters.)
error C2146: syntax error : missing ';' before identifier 'chunk_file'
error C2065: 'chunk_file' : undeclared identifier

Where am I wrong and why these lines wokrks with Borland and g++?

Thank you very much

Agos
Nov 17 '05 #1
4 1687
Agos wrote:
I'm trying to learn VC++.NET. I used till now Borland C++ Builder 6.
I had a program starting like this:

#include <fstream.h>
#define TEMP_FILES 200
......
.......
fstream chunk_file[TEMP_FILES];

With Borland and g++ I had no problems with these lines instead VC++.NET
tells me that can't find #include <fstream.h>
I saw that it works with
#include <fstream> (without .h)
but if I use the header files this way I get an error in this declaration:

fstream chunk_file[TEMP_FILES];

So if I try to build this short program:
=========================================
#include "stdafx.h"
#include <fstream>
#define TEMP_FILES 200

int _tmain(int argc, _TCHAR* argv[])
{
fstream chunk_file[TEMP_FILES];
return 0;
}
================================================== ===

VC++ gives me these errors:

error C2065: 'fstream' : undeclared identifier
(in fatc it knows what fstream is: A type basic_fstream specialized on char
template parameters.)
error C2146: syntax error : missing ';' before identifier 'chunk_file'
error C2065: 'chunk_file' : undeclared identifier

Where am I wrong and why these lines wokrks with Borland and g++?

Thank you very much

Agos

Because the version of the Borland compielr and its libraries are not
conformant to the C++ standard.

fstream does not exist. std::fstream is the class in the standard.

using namespace std;

is the quick fix.

Ronald Laeremans
Visual C++ team
Nov 17 '05 #2
Thank you vgery much :-)
Just one thing .... also g++ compile that.

And one information: why C++ standard decided to eliminate the ".h" from
header files?

Anyway thank you indeed again.

Agos

"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> ha scritto nel
messaggio news:uk**************@TK2MSFTNGP15.phx.gbl...
Agos wrote:
I'm trying to learn VC++.NET. I used till now Borland C++ Builder 6.
I had a program starting like this:

#include <fstream.h>
#define TEMP_FILES 200
......
.......
fstream chunk_file[TEMP_FILES];

With Borland and g++ I had no problems with these lines instead VC++.NET
tells me that can't find #include <fstream.h>
I saw that it works with
#include <fstream> (without .h)
but if I use the header files this way I get an error in this
declaration:

fstream chunk_file[TEMP_FILES];

So if I try to build this short program:
=========================================
#include "stdafx.h"
#include <fstream>
#define TEMP_FILES 200

int _tmain(int argc, _TCHAR* argv[])
{
fstream chunk_file[TEMP_FILES];
return 0;
}
================================================== ===

VC++ gives me these errors:

error C2065: 'fstream' : undeclared identifier
(in fatc it knows what fstream is: A type basic_fstream specialized on
char template parameters.)
error C2146: syntax error : missing ';' before identifier 'chunk_file'
error C2065: 'chunk_file' : undeclared identifier

Where am I wrong and why these lines wokrks with Borland and g++?

Thank you very much

Agos

Because the version of the Borland compielr and its libraries are not
conformant to the C++ standard.

fstream does not exist. std::fstream is the class in the standard.

using namespace std;

is the quick fix.

Ronald Laeremans
Visual C++ team

Nov 17 '05 #3
"Agos" <ag*****@tin.it> wrote in message
news:%K********************@news4.tin.it...
Thank you vgery much :-)
Just one thing .... also g++ compile that.
That doesn't say much. g++ will compile lots of stuff that's not standard
compliant.

And one information: why C++ standard decided to eliminate the ".h" from
header files?


The ".h" versions of the iostreams header files were never standards
compliant. The original standard in 1998 defines only the versions without
the ".h". The ".h" versions are pre-standard, i.e. over 7 years out of
date, and support for them was deprecated in VC7 and dropped altogether in
VC7.1.

-cd
Nov 17 '05 #4
Thank you

Agostino

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
ha scritto nel messaggio news:e5**************@tk2msftngp13.phx.gbl...
"Agos" <ag*****@tin.it> wrote in message
news:%K********************@news4.tin.it...
Thank you vgery much :-)
Just one thing .... also g++ compile that.


That doesn't say much. g++ will compile lots of stuff that's not standard
compliant.

And one information: why C++ standard decided to eliminate the ".h" from
header files?


The ".h" versions of the iostreams header files were never standards
compliant. The original standard in 1998 defines only the versions
without the ".h". The ".h" versions are pre-standard, i.e. over 7 years
out of date, and support for them was deprecated in VC7 and dropped
altogether in VC7.1.

-cd

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Massimiliano Alberti | last post by:
My program is heavily template based, and I use the VC++, so I have to keep the templates in the header file. My .cpp files are quite empty (they are more a connection between header files). Now,...
1
by: Glenn M | last post by:
I have visual c++ 6.0 and i want to use a function (setupuninstalloeminf) in setupapi.h that was not part of the original setupapi.h shipped with vsc++ but was added later. how do i go about...
2
by: Karthik | last post by:
When I try to compile my VC++ program (am Using VS6.0). I get the following error in a header file ATLCONV.H. c:\program files\microsoft visual studio\vc98\atl\include\atlconv.h(52) : error...
4
by: Andrew Ward | last post by:
Hi All, I was wondering if it is possible to use precompiled headers without having to include a <stdafx.h> or whatever in every source file. My problem is that I have a project that makes heavy...
1
by: Tom | last post by:
This has got to be something really simple, but I'm pretty baffled... In the header file I define the class interfaces, in the CPP file the class functions, and the CPP file #includes the...
9
by: Daniel | last post by:
Hi, While I compile my old C++ source in VC.Net, rebulild whole project, there are always some header files are unvaliable like "fstream.h", "Dxguide.h".....etc. Did VC.Net remove the VC++'s...
9
by: chat | last post by:
Hi, every body. I have 3 files like this: -------------------------------------------------------- file name : header.h #ifndef TEST_H #define TEST_H int a=1; double b=0.5;
4
by: mickey22 | last post by:
Hi , I am new member to this group.I am given already developed C++ code with all header files. I was asked to utilize some of this code and perform new operation. When I try to include some...
1
by: kudi.prathyu | last post by:
Hi , I'm new to this group. I'm working on a project called video over IP using VC++ I 'm soo techy with VC++ or C++ language. I need to know few things firstly.. I'm trying to use rtp.h...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.