954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

input output in regards to dev c++ vs xcode

so for my computing project we have just started to work with using input and output of text files, the tutorial my teacher gave said to include these libraries, which i did

#inclue <fstream>
#include <iomanip>

and explains how to use

ifstream fin;  //fin is my file input variable
  		  ofstream  fout;  //fout is my file output variable

the problem is dev c++ doesnt seem to recognize this, my teacher works with xcode so is that whats messing this up? or does my version need an update or something? or does dev do this a different way than xcode? sorry this is kind of a dumb question but dumb questions are easily answered

beejay321
Light Poster
25 posts since Jan 2011
Reputation Points: 7
Solved Threads: 0
 

you have to tell the compiler that ifstream and ofstream are in std namespace. There are a couple ways to do that

#include <fstream>

using std::ifstream;
using std::ofstream;


or this

#inclue <fstream>
#include <iomanip>

int main()
{
   std::ifstream fin;
   std::ofstream fout;
}
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

you have to tell the compiler that ifstream and ofstream are in std namespace. There are a couple ways to do that

#include <fstream>

using std::ifstream;
using std::ofstream;

or this

#inclue <fstream>
#include <iomanip>

int main()
{
   std::ifstream fin;
   std::ofstream fout;
}


perfect! works fine now thanks!

beejay321
Light Poster
25 posts since Jan 2011
Reputation Points: 7
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: