I am currently using Putty virtual machine (UNIX) for my class, and we are doing a short C++ assignment. The assignment is to: "Create a C++ program that tests to see if the file accounts exists and prints a message to say whether the file exists"
This is what I have, but when I try to compile the code, I get this error: error: ‘::main’ must return ‘int’
#include<iostream>
#include<fstream>
using namespace std;
inline bool exists_test1 (const std::string& name) {
if (FILE *file = fopen(name.c_str(), "r")) {
fclose(file);
return true;
} else {
return false;
}
}
void main()
{
string s;
cout<<"Enter filename";
cin>>s;
bool ans =exists_test1(s);
if(ans)
{
cout<<"File Exist"<<endl;
}
else
{
cout<<"File Does not Exist";
}
}