#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream inputFile;
string example;
int numbers,
totalNumbers = 0;
// Prompt user to input name of the file to open
cout << "Please enter the name of the program" << endl;
cin >> example;
// Open the input file that is assigned to the variable 'example'
inputFile.open(example.c_str());
// If the file successfully opened, process it
if(inputFile)
{
// Loop until the EOF is reached
while(inputFile >> numbers) // If a value was read
{
totalNumbers += numbers;
}
// Close the file
inputFile.close(example.c_str());
cout << totalNumbers;
}
else
{
// Display an error message
cout << "could not access file";
}
return 0;
}
derleme ++ std :: basic_ifstream :: close (const char *) ' inputFile.close (örnek.c_str()); ^ fileAdder.cpp: 36: 40: not: aday: Dosya içeriğinde bulunan dosyaAdder.cpp: 8: 0: /usr/include/c++/4.8.2/fstream:576:7: note: void std :: basic_ifstream < _CharT, _Traits> :: close() [withCharT = char; _Traits = Std :: char_traits] yakın() ^ /usr/include/c++/4.8.2/fstream:576:7: Not: Aday, 1Cı hatası aşağıdaki gibidir hatayı
Oku geçmesi gerekmez Hata mesajı, sorun oldukça açık bir şekilde belirtilmiştir. – anukul