So i just started my project on a cpu sim , but right of the bat i ran into a problem

#include <cstdlib>
#include <fstream>
#include <iostream>
using namespace std;

/*
 * 
 */
int main(int argc, char** argv) 
{

    return 0;
}
void cpu()
{

}
void memory()
{
    int memArray[1000];
    ifstream infile;
    infile.open("program.txt");

}

my ifstream is having trouble, i think it has to do with the headers but i dont know how to fix this , am kind of bearly picking up c++ again.
So any help is appriciated, ok between using netbeans ide, and i also already tried this with vi and the error i got is that "ifstream was not declated on the scope" or something along those lines, any help?

Recommended Answers

All 2 Replies

Your code seems fine, it might be how you setup the environment. How'd you set up your environment? I haven't used netbeans in years. But typically in any ide, there is an option to create a C++ project. Did you try to run a simple hello-world program and see if that works:

#include <iostream>
using namespace std;
int main(){
  cout << "TEST" << endl;
  return 0;
}

i was able to fix this, apearantly after i compiled it it fixed the problem, i still dont understand why in vi it dint work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.