.

.kkk
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/doc/tutorial/files/
Looked at both links thanks! but it hasnt helped, even with a cout the program is executing a blank program, I cant seem to get the integers from the text file :(
Please, show your latest code.
Use code tags too. See http://www.cplusplus.com/articles/jEywvCM9/
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main ()

{
string line;
ifstream myfile ("numbers.txt",ios::out);
if (myfile.is_open())
while ( getline (myfile,line) )

cout << line << endl;



cin.get();
cin.ignore();
return 0;
}

i am getting a blank program using this, the name of my text file is "numbers.txt" without quotations
The ios::out on infile ... try ifstream myfile ( "numbers.txt" );
ifstream myfile ("numbers.txt",ios::out);
You are creating an output-based file with an input-based class (ios::out with std::ifstream).
No wonder you're getting no input.
Remove ios::out completely, a default value will be provided.
here is my task

You are required to produce an application that will inform the user if the weight of ship once the containers are aboard is legal.
To do this you must first read eight numbers from a text file;
 the dimensions of the ship cargo hold (length x width x height)
 the dimension of a container (length x width x height)
 the average weight of a full container
 the maximum legal weight of cargo
These numbers should be entered into the file manually before the application runs.
I done it I just needed text.open
Last edited on
Wow, you're so great, I didn't know about that.
Topic archived. No new replies allowed.