473,698 Members | 2,086 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1703
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******** ******@TK2MSFTN GP15.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******** ************@ne ws4.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.nos pam>
ha scritto nel messaggio news:e5******** ******@tk2msftn gp13.phx.gbl...
"Agos" <ag*****@tin.it > wrote in message
news:%K******** ************@ne ws4.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
2692
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, my "problem" is that I can't put the body of classless functions in the header files. I normally "solve" this problem using the "inline" keyword (inline functions must be in header files, but the compiler doesn't have to "inline" inline functions)....
1
2306
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 getting the newer header file with the newer function on my system. simply copying the header file from my visual c++.net install to the vsc++ install seems to produce errors. do i need to copy across a newer verion of setupapi.lib too, is that...
2
6124
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 C2065: '_ASSERTE' : undeclared identifier Error executing cl.exe. and it points to inline LPWSTR WINAPI AtlA2WHelper(LPWSTR lpw, LPCSTR lpa, int nChars,
4
2515
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 usage of a large third party library which means after pre-processing each translation unit is around 1meg in size. There are reasons though why I cannot use the standard approach to precompiled headers. What I would like to do is somthing like...
1
939
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 header file. Looks like Stroustrup style code. The only way I can get it to complile is to declare (again) the class within the cpp file. If I don't redeclare it but instead just put all the
9
1899
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 headers? How can I get them back? Where sould I put them in?
9
4042
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
2087
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 header files which I have been developed by somebody else it is showing erors in those header files.I tried to include all the directories related th this header files. The errors are like syntax error: missing ; before identifier 'uint 64' .When I...
1
1591
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 header file and trying to add another header in the compiler. What is the procedure for that.....can any one pls help me
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.