Thread: Visual C++ 2003 header problem

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    8

    Visual C++ 2003 header problem

    hello, I'm using Visual studio 2003 for the first time, and I have run into a problem, when I try to include *any standard header file, it tells me that it doesn't exist, though I have fiddled with the 'precompiled header' stuff, tuning it on and off, I can't seem to solve this, here is an example:

    Code:
    #include <fstream.h>
    int main()
    {
    	char str[2000];
    	fstream file_op("test.txt",ios::in);
    	while(file_op >> str)
    	
    		cout << str;
    	
    
    	file_op.close();
    
    	return (0);
    }
    Code:
    fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
    Thanks in advance
    Last edited by j0seph; 07-03-2005 at 02:20 AM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    If you double click on the error it should bring you to the offending line. fstream.h has been removed completely and you should be using fstream instead. Also make sure you make use of the std namespace when you are using objects declared within that namespace.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    8
    well, when I try to use the precompiled headers, I just get the following error:

    Code:
    fatal error C1010: unexpected end of file while looking for precompiled header directive
    // EDIT : I decided to just use Dev C++, and everything works fine now, but thanks anyway MrWizard
    Last edited by j0seph; 07-03-2005 at 02:43 AM.

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    37
    How about this.

    Code:
    #include <fstream>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	char str[2000];
    	fstream file_op("test.txt",ios::in);
    	while(file_op >> str)
    	
    		cout << str;
    	
    
    	file_op.close();
    
    	return (0);
    }
    Compiler: MS Visual C++.net 2003
    OS: MS Windows XP sp2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. MS Visual C++ 6 wont include vector.h in a header file
    By bardsley99 in forum C++ Programming
    Replies: 9
    Last Post: 11-06-2003, 12:05 PM
  4. Header file problem
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 05-08-2002, 08:24 AM
  5. Visual Basic Adodc Problem
    By rahat in forum Windows Programming
    Replies: 1
    Last Post: 01-20-2002, 06:55 AM