I'm trying to make a program that checks if a file is there, if not make it with some writting in it. I've done my best make sure everything is correct.
Code:
Code:
/* Section: header */
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
/* Section: constant */
const std::string NEWLINE = "\n"
const std::string NEWLINE_FLUSH = "std::endl"
/* Section: prototype */
void nfound( const std::string &v_file );
int main( int argc, char *argv[] ) {
using namespace std;
string the_file = "test_file.txt";
if ( "the_file" ) {
cout << "File found!";
} else {
cout << "File not found!";
nfound( "the_file" );
}
cin.get();
return 0;
}
void nfound( const std::string &v_file ) {
using namespace std;
ofstream a_file ( "v_file" );
a_file << "This text will go inside!NEWLINE";
a_file.close();
}
Errors:
|9|error: expected ',' or ';' before 'const'|
||In function 'int main(int, char**)':|
|21|error: 'nfound' was not declared in this scope|