Little Help with a program here please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cabenuts
    New Member
    • Jul 2007
    • 3

    Little Help with a program here please

    Hello ok the scope of this program I need to go to a file open and bring some doubles from that file into and array this is what I got so far and it says I retrieved 0 files hmmm if anyone can help I would appreciate it....
    [code=cpp]
    #include <iostream>
    #include <cstdlib>
    #include <iomanip>
    #include <fstream>

    using namespace std;

    int main ()
    {

    const int SIZE = 150;
    double data [SIZE];
    double input;
    int index = 0;

    ifstream fin;
    fin.open ("data07.fp100. ");
    while ( fin >> input )
    {
    data [ index++ ] = input;
    if ( index >= SIZE ) break;
    }
    fin.close( );
    cout << "\n" << index << " fp numbers were read from disk file.";

    for ( int i = 0; i < index; ++i )
    {
    if ( i % 5 == 0 ) cout << "\n";
    cout << setw (14) << data [ i ];
    }
    }[/code]
    Last edited by sicarie; Jul 12 '07, 02:38 PM. Reason: Please use [code=cpp] and [/code] tags around your code.
  • scruggsy
    New Member
    • Mar 2007
    • 147

    #2
    Originally posted by cabenuts
    Hello ok the scope of this program I need to go to a file open and bring some doubles from that file into and array this is what I got so far and it says I retrieved 0 files hmmm if anyone can help I would appreciate it....
    Your code is fine.
    Make sure the file exists in the working directory, contains data, is named properly, and doesn't have an extension (like .txt) which may not be visible in windows explorer.

    Comment

    • cabenuts
      New Member
      • Jul 2007
      • 3

      #3
      I figured it out if you look at teh file there is an extra period lol sometimes its simple things I guess

      Comment

      Working...