Is there anything wrong with this source code?

Discussion in 'Mac Programming' started by hotglass, Aug 9, 2008.

  1. hotglass macrumors newbie

    Aug 9, 2008
    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; ("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;

    [Process completed]
  2. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

    Aren't you missing:-

    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

Share This Page