Sign in to follow this  
HemoGloben

Deprecated Headers....

Recommended Posts

I'm practacing my Input streams, and I can't seem to get them to work. I just installed a clean Dev C++ install, and I get errors about Deprecated Headers being included.
#include <fstream.h>
#include <iostream>

int main(void)
{
    fstream FileOne;
    char temp[512];
    FileOne.open("C:\Documents and Settings\Hello\Desktop\Phrases.txt", ios::in);
    if(FileOne.is_open())
    {
        std::cout << FileOne.get(temp, 512, '\n');
    }
    FileOne.close();
    return 0;
}        
Errors:
Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Dev-Cpp\main.cpp" -o "C:\Dev-Cpp\main.exe"    -I"C:\Dev-Cpp\include\c++"  -I"C:\Dev-Cpp\include\c++\mingw32"  -I"C:\Dev-Cpp\include\c++\backward"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib" -L"C:\Program Files\Microsoft Visual Studio\VC98\Lib" 
In file included from C:/Dev-Cpp/include/c++/backward/fstream.h:31,
                 from C:/Dev-Cpp/main.cpp:1:
C:/Dev-Cpp/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
C:/Dev-Cpp/main.cpp:8:18: warning: unknown escape sequence '\D'
C:/Dev-Cpp/main.cpp:8:18: warning: unknown escape sequence '\H'
C:/Dev-Cpp/main.cpp:8:18: warning: unknown escape sequence '\D'
C:/Dev-Cpp/main.cpp:8:18: warning: unknown escape sequence '\P'
C:/Dev-Cpp/main.cpp: In function `int main()':
C:/Dev-Cpp/main.cpp:8: error: `ios' undeclared (first use this function)
C:/Dev-Cpp/main.cpp:8: error: (Each undeclared identifier is reported only once 
   for each function it appears in.)
C:/Dev-Cpp/main.cpp:8: error: syntax error before `::' token

Execution terminated

Any help?

Share this post


Link to post
Share on other sites
your compiler tells you that your using a deprecated header ;) which is deprecated since '98. thats six years now and you still dont now it? well your code should look something like this:


#include <iostream>
#include <string>
#include <fstream>

int main () {
std::ifstream inputFile ( "C:\\..." ); // now everything is in the std:: namespace; and if you want to have a path use either \\ or / ( the compiler warned you and you should have corrected this yourself )

if ( inputFile.is_open () ) {
std::string content; // either use c++ and stick to std::string or go c and use char* ( which i dont recommend ) but because you have chosen streams i guess you want to make a c++ program

inputFile.getline ( content, '\n' );

std::cout << content;
}

std::cin.clear ();
std::cin.ignore ( std::cin.rdbuf () -> in_avail () );
std::cin.get ();
return 0;
};



was auch immer

EDIT: Replaced code tags with source tags

[Edited by - 23yrold3yrold on September 2, 2004 6:23:51 PM]

Share this post


Link to post
Share on other sites
Thanks for that. Didn't realize all the dropped .h extensions. I was using Game Programming all in one, which says to use the .h, and a lot of other things(surprisingly copyrighted in 2002, gotta check alot of that info then).

Anyone know of any online resources to learn about streams in C++? Thanks

Share this post


Link to post
Share on other sites
Thanks.

And I was in the process of googling, but my connection was really going south(I think there's something messingup my wireless connection to the base station).

But that's exactly what I was lookin for, thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this