visual c++ - C++ file input, stream, and compile -
so problem i'm getting error c3867 when i'm attempting close file stream (at least that's hope i'm doing). intent make program uses input file read in values array , there determine highest , lowest numbers of array are. arraysize can less or more 10 data items, , must check file open errors before reading data file , close file after finished reading elements array. can later it's instruction anyway.
#include <stdafx.h> #include <iostream> #include <fstream> #include <string> using namespace std; int main(){ const int arraysize = 10; float numbers[arraysize]; int count = 0; string filename; float high, low; fstream inputfile(filename, ios::in); cout << "what filename wish use? "; cin >> filename; inputfile.open(filename); while (count < arraysize && inputfile >> numbers[count]) count++; inputfile.close; high = numbers[0]; low = numbers[0]; (int = 0; < arraysize; i++){ if (numbers[i] > high) high = numbers[i]; if (numbers[i] < low) low = numbers[i]; } cout << "the highest number in file is: " << high; cout << "the lowest number in file is: " << low; return 0; } am missing anything?
you need call inputfile.close() function parentheses.
Comments
Post a Comment