During compilation, the system prompts that the file including "fstream. H" cannot be opened"

Source: Internet
Author: User

# Include <fstream. h> method, but fatal errorc1083 is prompted during compilation: The file including "fstream. h ": no such file or directory.

After reading the relevant information, find the solution:

Set

 
# Include <fstream. h>

 

Change

 
# Include <fstream>UsingNamespaceSTD;

 

Compilation and running are successful ~~~

 

Why?

Because:

The old iostream library is removed from Visual C ++. NET 2003.

The major difference between the standard C ++ Library and the previous Runtime Library is the iostream library. Iostream implementation
The details have been changed. to link to the Standard C ++ library, it may be necessary to rewrite it.CodeUsing iostream
.

You must remove any old iostream header files (fstream. H, iomanip. H, Ios. h
, Iostream. H, istream. H, ostream. H, streamb. H, and strstrea. H), and add
Or Multiple New Standard C ++ iostream header files (<fstream>, <iomanip>, <IOS>, and <iosfwd>
, <Iostream>, <istream>, <ostream>, <sstream>, <streambuf>, and <strstream>
, All header files do not have the. h extension ).

In the new Standard C ++ iostream Library:
1. The open function does not use the third parameter (Protection parameter ).
2. You cannot create a stream from the file handle.
3. Except for a few exceptions, all the names in the new Standard C ++ library are in the STD namespace. For more information, see use the C ++ library header.
4. The ofstream object cannot be opened with the IOS: Out flag. The IOS: Out sign must be combined with another IOS enumeration number in the logic or. For example, it must be combined with IOS: In or IOS: app.
5. Because the eofbit status is set, no non-zero value is returned for iOS: good after the file is reached. IOS: SETF (_ iflags)

It should not be used with the flag value of IOS: Dec, IOS: Oct, or IOS: Hex. Formatted input/output functions and operators are assumed to have only one base. Use ios_base instead.

For more information about the changes, refer to msdn ~

Except for the above changes, the following functions, constants, and enumerations used as elements of the old iostream library are not new iostreams.
Library element:
Attach Member functions of filebuf, fstream ifstream, and ofstream
FD member functions of filebuf, fstream ifstream, and ofstream
Filebuf: openprot
Filebuf: setmode
IOS: bitalloc
IOS: nocreate
IOS: noreplace
IOS: sync_with_stdio
Streambuf: out_waiting
Streambuf: setbuf (the same behavior uses rdbuf-> pubsetbuf)

From: http://www.cnblogs.com/lingshaohu/archive/2011/11/07/2239453.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.