SprayKid982
SprayKid982

Reputation: 333

Cannot use ifstream in Xcode

I am new to C++ and have researched this everywhere and cannot seem to figure out how to compile this and have not idea why. It works in visual C++ but not Xcode. The error seems to be on the input stream. Any suggestions?

Error reads - "Implicit instantiation of undefined template 'std::_basic_ifstream >'

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

int main()
{
    cout  << "The file is providing the data.";
    ifstream myFile("/Users/me/Desktop/somewords.txt"); // * error

    int i;
    string s;
    double d;
    myFile >> i >> s >> d;
    cout << "here is your data " << endl;
    cout << i << endl << s << endl << d << endl;


    return 0;
}

Upvotes: 1

Views: 2675

Answers (1)

Cornstalks
Cornstalks

Reputation: 38228

You forgot to #include <fstream>, the header file that actually defines all your ifstream goodness. You included <iostream> twice (or at least tried to), perhaps one of those was meant to be <fstream>?

Upvotes: 6

Related Questions