Skip to main content
gamedev.net
🔒 Locked

VC++ Binary Text Output Error

Started by CppBeginnerNerd Jan 8, 2004 at 10:05 PM 2 replies 350+ views
Original Post
CppBeginnerNerd
CppBeginnerNerd
For some reason my VC++ Standard 2003 gives me an error on fstream, what did i do wrong, my book uses it so i have no clue , this is also a common #include , heres the error fatal error C1083: Cannot open include file: ''fstream.h'' /* ''10 Main.cpp'' */ /* File stream header file */ #include <fstream.h> /* Input Output stream header file */ #include <iostream> /* Start */ main (void) { /* File stream */ fstream File; /* Program data */ char FirstName [256]; char LastName [256]; int Age; char IsMarriedReturn; bool IsMarried; /* Open the file for output */ File.open ("Data.bin", ios::out | ios::binary); /* If file was opened successfully continue */ if (File.is_open ()) { std::cout << "What is your first name: "; std::cin >> FirstName; std::cout << "What is your last name: "; std::cin >> LastName; std::cout << "What is your age: "; std::cin >> Age; std::cout << "Are you married (y for yes, anything else for no): "; std::cin >> IsMarriedReturn; if ((IsMarriedReturn == ''y'' || IsMarriedReturn == ''Y'')) { IsMarried = true; } else { IsMarried = false; } /* Write data to file */ File.write ((char *) &FirstName, sizeof (char) * 256); File.write ((char *) &LastName, sizeof (char) * 256); File.write ((char *) &Age, sizeof (int) ); File.write ((char *) &IsMarried, sizeof (bool) ); /* Close file */ File.close (); } system("pause"); return 0; }
Read the Bible, It will scare the Hell out of you therefore making you a Christian(j/k give your life to Christ then you are Christian)
pinacolada
pinacolada
shot in the dark, try this:

#include <fstream>

or this:

#include "fstream.h"
Chris Hare
Chris Hare


#include <fstream>

and either

using std::fstream; // if in a .h file (header)

or

using namespace std; // if in a .cpp file (source)




blah blah blah.
psykr
psykr
Don''t use fstream.h, it''s deprecated. Use just plain <fstream>. Also, when this has fixed your problem, fstream is part of the std namespace, so write a using directive or prefix std to the variable definition, like Chris Hare said.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.