Jump to content
  • Advertisement
Sign in to follow this  

Deprecated Headers....

This topic is 5008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!