Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hotglass

macrumors newbie
Original poster
The inFile was made in Word for Mac and it contains the number 5.50. When I run this, it is successful, yet there is just a blank output, where I want it to display the number 5.50.


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

int main (int argc, char * const argv[])
{
double dec;
ifstream inFile;
inFile.open ("sample.txt");
inFile >> fixed >> showpoint;

inFile >> dec;

return 0;

}

This is the output:

Last login: Sat Aug 9 16:24:36 on ttys003
/Users/lucasmoderacki/sample/build/Release/sample ; exit;
macintosh:~ lucasmoderacki$ /Users/lucasmoderacki/sample/build/Release/sample ; exit;
logout

[Process completed]
 
Hi

Aren't you missing:-

Code:
cout << dec << endl ;

or something like it?

Also you may want to use the full file path to sample.txt to avoid and ambiguity between your project and current directory.

b e n
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.