ifstream problems

This is a discussion on ifstream problems within the C++ Programming forums, part of the General Programming Boards category; -ken- helped me take the 11 errors to 4 by adding std:: before everything, but since this is my first ...

  1. #1
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    ifstream problems

    -ken- helped me take the 11 errors to 4 by adding std:: before everything, but since this is my first time using ifstream (ya haha laugh it up), these last four got me stuck. All of them are from this class:

    Code:
    void Open_Check_Resp::load_file()
    {
    	std::ifstream infile;
    
    	char test;
    
    	infile.open("C:\\checkresp.txt");
    
    	infile >> test;
    
    	infile.close();
    
    	std::cout << test;
    }
    the errors are:

    Code:
    --------------------Configuration: ChatBot - Win32 Debug--------------------
    Compiling...
    ChatBot.cpp
    C:\Program Files\Microsoft Visual Studio\MyProjects\ChatBot\ChatBot.cpp(84) : error C2079: 'infile' uses undefined class 'basic_ifstream<char,struct std::char_traits<char> >'
    C:\Program Files\Microsoft Visual Studio\MyProjects\ChatBot\ChatBot.cpp(88) : error C2228: left of '.open' must have class/struct/union type
    C:\Program Files\Microsoft Visual Studio\MyProjects\ChatBot\ChatBot.cpp(90) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
    C:\Program Files\Microsoft Visual Studio\MyProjects\ChatBot\ChatBot.cpp(92) : error C2228: left of '.close' must have class/struct/union type
    Error executing cl.exe.
    
    ChatBot.obj - 3 error(s), 1 warning(s)
    and heres the includes list:

    Code:
    #include <iostream>
    #include <string>
    #include <ctype.h>
    #include <time.h>
    #include <fstream.h>
    using namespace std;

  2. #2
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Take the .h off of <fstream>
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    least my probs r easy....thnx man

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 04:48 PM
  2. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  3. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 08:19 PM
  4. Read problems
    By xddxogm3 in forum C++ Programming
    Replies: 10
    Last Post: 10-05-2003, 12:17 AM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 03:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21