Deprecated Headers....

Started by
4 comments, last by HemoGloben 19 years, 7 months ago
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?
if(this.post == SATISFYING){money.send(1.00,&HemoGloben);return thanks;}
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]
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
if(this.post == SATISFYING){money.send(1.00,&HemoGloben);return thanks;}
There's a useful iostream reference here and Bruce Eckel's Thinking in C++ Vol 2 covers them pretty well (it's a free full book on C++ by one of the greats).
I guess you could try www.cplusplus.com. Or [google].

EDIT: Beaten ...

Jesus saves ... the rest of you take 2d4 fire damage.

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.
if(this.post == SATISFYING){money.send(1.00,&HemoGloben);return thanks;}

This topic is closed to new replies.

Advertisement