I NEED HELP WITH FILES

I have read through the tutorials on here and I just cant get my head around it. Alls i need to do is be able to open a file and then use it in my program. I am using microsoft visual studio 2010. My file is titled Value.txt. The file only contains 3 numbers and then an equation. My aim is to open the file using c++ then asign the 3 numbers to an integer, like int Length for example. Then I need to have Int Answer as the equation so that when i run the program the equation is worked out and then shown on screen. Can any one please help.
All you need is three lines of code.

Header:
1
2
#include <iostream>
#include <fstream> 

Within main(), std::ifstream fin("filename.txt");

After that you can use fin to get values from the file in exactly the same way that you use cin to get values from the user. ("fin" can be any name you like);
This is how my code starts is that all wrong then as when i try ifstream in this it just isnt having any of it.

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, char* argv[])

{
Your code is ok as far as it goes, but there's no way to diagnose the issue without seeing more of your code. Could you explain "it just isnt having any of it" please.
I have it working now thanks to what you said :) thanks alot
Topic archived. No new replies allowed.