what is different between <fstream.h> and <fstream>MS VC++

Discussion in 'C++' started by Armando, Jan 28, 2004.

  1. Armando

    Armando Guest

    Hallo !

    I habe some error in my programm,because i use <fstream.h>,I want to
    use <fstream> but i don´t know which fonctions i must modify in my
    program ?

    Thanks you for your help.

    Armando.
    Armando, Jan 28, 2004
    #1
    1. Advertising

  2. Armando

    Sharad Kala Guest

    "Armando" <> wrote in message
    news:...
    > Hallo !
    >
    > I habe some error in my programm,because i use <fstream.h>,I want to
    > use <fstream> but i don´t know which fonctions i must modify in my
    > program ?
    >
    > Thanks you for your help.


    What are the errors?
    Are you writing 'using namespace std;' in your program?
    Sharad Kala, Jan 28, 2004
    #2
    1. Advertising

  3. Armando

    Armando Guest

    "Sharad Kala" <> wrote in message news:<bv82kc$ouhgm$-berlin.de>...
    > "Armando" <> wrote in message
    > news:...
    > > Hallo !
    > >
    > > I habe some error in my programm,because i use <fstream.h>,I want to
    > > use <fstream> but i don´t know which fonctions i must modify in my
    > > program ?
    > >
    > > Thanks you for your help.

    >
    > What are the errors?
    > Are you writing 'using namespace std;' in your program?


    yes i am writing 'using namespace std ;' and the errors are

    error C2228: left of '.open' must have class/struct/union type
    error C2228: left of '.eof' must have class/struct/union type
    error C1903: unable to recover from previous error(s); stopping
    compilation
    Error executing cl.exe.

    and my header file is here:

    #ifndef _XML_H
    #define _XML_H

    #include<fstream>
    #include<string>
    using namespace std;

    class XML
    {
    private:

    ifstream fileread;
    ofstream filewrite;

    public:

    // For reading file and inserting the key and value pairs into
    XML file
    static void readfile(char *infile,string key1,string
    text1,string str_value,string val);

    // Function for converting the function parameters into XML file
    static void writeXML(char *infile,string val,char *path);

    // retrieving the value
    string getValue(char *infile,char *path);

    };
    #endif // _XML_H
    Armando, Jan 28, 2004
    #3
  4. Armando wrote:
    >
    > "Sharad Kala" <> wrote in message news:<bv82kc$ouhgm$-berlin.de>...
    > > "Armando" <> wrote in message
    > > news:...
    > > > Hallo !
    > > >
    > > > I habe some error in my programm,because i use <fstream.h>,I want to
    > > > use <fstream> but i don´t know which fonctions i must modify in my
    > > > program ?
    > > >
    > > > Thanks you for your help.

    > >
    > > What are the errors?
    > > Are you writing 'using namespace std;' in your program?

    >
    > yes i am writing 'using namespace std ;' and the errors are
    >
    > error C2228: left of '.open' must have class/struct/union type
    > error C2228: left of '.eof' must have class/struct/union type


    those errors don't seem to be related to either the fstream header
    or the ifstream header.

    The error message looks like VC++ generated it. If so there is a line
    number next to it. What line does it refere to?


    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Jan 28, 2004
    #4
  5. Armando

    Deming He Guest

    Armando <> wrote in message
    news:...
    > "Sharad Kala" <> wrote in message

    news:<bv82kc$ouhgm$-berlin.de>...
    > > "Armando" <> wrote in message
    > > news:...
    > > > Hallo !
    > > >
    > > > I habe some error in my programm,because i use <fstream.h>,I want to
    > > > use <fstream> but i don´t know which fonctions i must modify in my
    > > > program ?
    > > >
    > > > Thanks you for your help.

    > >
    > > What are the errors?
    > > Are you writing 'using namespace std;' in your program?

    >
    > yes i am writing 'using namespace std ;' and the errors are
    >
    > error C2228: left of '.open' must have class/struct/union type
    > error C2228: left of '.eof' must have class/struct/union type
    > error C1903: unable to recover from previous error(s); stopping
    > compilation
    > Error executing cl.exe.
    >
    > and my header file is here:
    >
    > #ifndef _XML_H
    > #define _XML_H
    >
    > #include<fstream>
    > #include<string>
    > using namespace std;
    >
    > class XML
    >


    > private:
    >
    > ifstream fileread;
    > ofstream filewrite;
    >
    > public:
    >
    > // For reading file and inserting the key and value pairs into
    > XML file
    > static void readfile(char *infile,string key1,string
    > text1,string str_value,string val);
    >
    > // Function for converting the function parameters into XML file
    > static void writeXML(char *infile,string val,char *path);
    >
    > // retrieving the value
    > string getValue(char *infile,char *path);
    >
    > };
    > #endif // _XML_H


    You probably used a pointer to an ifstream object as an ifstream object.
    For example:

    ifstream *pifs;
    ....
    pifs.open("xmldata.xml");

    or used a whatever object that wasn't an ifstream.
    Deming He, Jan 28, 2004
    #5
  6. Armando

    Old Wolf Guest

    > > > I habe some error in my programm,because i use <fstream.h>,I want to
    > > > use <fstream> but i don´t know which fonctions i must modify in my
    > > > program ?

    >
    > yes i am writing 'using namespace std ;' and the errors are
    >
    > error C2228: left of '.open' must have class/struct/union type
    > error C2228: left of '.eof' must have class/struct/union type
    > error C1903: unable to recover from previous error(s); stopping
    > compilation
    > Error executing cl.exe.
    >
    > and my header file is here:
    >


    #include <iostream>

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

    (etc.)

    You might find that you need
    #include <istream>
    and/or
    #include <ostream>
    too.
    Old Wolf, Jan 28, 2004
    #6
  7. Armando

    Armando Guest

    (Old Wolf) wrote in message news:<>...
    > > > > I habe some error in my programm,because i use <fstream.h>,I want to
    > > > > use <fstream> but i don´t know which fonctions i must modify in my
    > > > > program ?

    > >
    > > yes i am writing 'using namespace std ;' and the errors are
    > >
    > > error C2228: left of '.open' must have class/struct/union type
    > > error C2228: left of '.eof' must have class/struct/union type
    > > error C1903: unable to recover from previous error(s); stopping
    > > compilation
    > > Error executing cl.exe.
    > >
    > > and my header file is here:
    > >

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

    > (etc.)
    >
    > You might find that you need
    > #include <istream>
    > and/or
    > #include <ostream>
    > too.

    //==============================================================================
    Thanks you everybody
    i am writting 2 programs in VC++ 6.0, one for XML files the header is
    up i have no problem which them it is ok, and the second programm is a
    dynamic table to memory some data typ is ok. but i want to put the
    both pragrams together (2 classes in 1) and i don´t any code of
    program and try to compile alone the xml.cpp file and i become this
    errors.

    Compiling...
    xml.cpp
    \config\xml.cpp(164) : error C2228: left of '.open' must have
    class/struct/union type
    config_xml_1\config\xml.cpp(167) : error C2228: left of '.eof' must
    have class/struct/union type
    config_xml_1\config\xml.cpp(167) : fatal error C1903: unable to
    recover from previous error(s); stopping compilation
    Generating Code...
    Compiling...
    Config.cpp
    Generating Code...
    Error executing cl.exe.

    Config.exe - 3 error(s), 0 warning(s)
    #===============================================================================
    here are the errors line from the xml.cpp

    the first ==> fileread.open(infile,ios::in);

    the second ==> while(!fileread.eof())



    #===============================================================================
    here are the headers of the both programs.
    #===============================================================================
    #ifndef _XML_H
    #define _XML_H

    #include<fstream>
    #include<string>
    using namespace std;

    class XML
    {
    private:

    ifstream fileread;
    ofstream filewrite;

    public:

    // For reading file and inserting the key and value pairs into
    XML file
    static void readfile(char *infile,string key1,string
    text1,string str_value,string val);

    // Function for converting the function parameters into XML file
    static void writeXML(char *infile,string val,char *path);

    // retrieving the value
    string getValue(char *infile,char *path);


    };

    #endif // _XML_H

    #===============================================================================
    #ifndef _Config_h
    #define _Config_h

    #include <dynamictable.h>
    #include <strings.h>

    class Config {

    private:

    DynamicTable<String *> Values ;

    String filename , path ;

    public:

    // StandardKonstruktor
    Config();
    // Konstruktor
    Config (String , String);
    // Desrtruktor
    ~Config();

    // PutString -- Put a string value (true string) into the DynamicTable
    char* PutString(String Key, String Value);
    // void PutString(String Key, String Value);
    // GetString -- Get a string value (true string) from the DynamicTable
    String GetString (String Key);

    // PutColor -- Put a color value into the DynamicTable
    void PutInt(String key , int value);

    // PutFloat -- Put a color value into the DynamicTable
    void PutFloat (const char * Name, double Value);

    // PutColor -- Put a color value into the DynamicTable
    void PutColor (const char * Name, const COLORREF Value = 0);

    // GetFloat -- Get a floating-point value from the DynamicTable
    double GetFloat (String key);

    // GetInt -- Get a Int value from the DynamicTable
    int GetInt (String key);

    // GetColor -- Get a color (COLORREF) value from the DynamicTable
    COLORREF GetColor(String key);

    // Save the value
    void save ();

    };
    #endif // Config_h

    #===============================================================================

    THX

    Armando
    Armando, Jan 29, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    11,982
  2. Flip
    Replies:
    0
    Views:
    289
  3. Santa
    Replies:
    1
    Views:
    1,049
    Mark A. Odell
    Jul 17, 2003
  4. Joona I Palaste
    Replies:
    14
    Views:
    1,410
    Fred Bloggs
    Jan 20, 2004
  5. PerlFAQ Server
    Replies:
    0
    Views:
    333
    PerlFAQ Server
    Jan 6, 2011
Loading...

Share This Page