ofstream fails to open file for output

it is failing on the 1022 symbol read.

// 1022 is the count of the current symbol to download history for.
// 1021 symbols have already been downloaded with no problem.
// BIL is the stock symbol
// Yahoo is the site feed used

Output of verbose:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1022	BIL	Yahoo
1022	Yahoo history found
could NOT open for output
save file symbol: BIL

// history_csv contents to write to the file.
Date,Open,High,Low,Close,Volume,Adj Close
2012-03-23,45.82,45.83,45.82,45.83,206

File NOT exists

// marker to show if made it to sql statement
1022	active_feed

terminate called after throwing an instance of 'sql::SQLException'
  what():  File 'yhistory.csv' not found (Errcode: 24)
Aborted

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
            found = history_csv.find( "Date," );
            if ( found == 0 )
            {
                if( verbose ) cout<<counta<<"\tYahoo history found"<<endl;
                file_csv.open("yhistory.csv");
                if( !file_csv )
                    cout<<"could NOT open for output"<<endl;
                file_csv << history_csv;
                file_csv.close();

                cout<<"save file symbol: "<<y_symbol<<endl;
                cout<<history_csv.substr(0, 80)<<endl;
                file_test.open("yhistory.csv" );
                if( file_test.is_open() )
                {
                    cout<<"File exists"<<endl;
                    file_test.close();
                } else
                    cout<<"File NOT exists"<<endl;
            } else


The file yhistory.csv is deleted after inserting it into Mysql DB
and then back around for the next symbol.
Topic archived. No new replies allowed.