The goal of this program is to take a file and ask the user for nouns, verbs, etc. in order to fill out a sentence. The new results will be saved to a second file. I keep receiving the following errors:
prog5B.cpp: In function ‘int openInfile()’:
prog5B.cpp:47: error: expected initializer before ‘.’ token
prog5B.cpp:48: error: ‘ins’ was not declared in this scope
prog5B.cpp: In function ‘void openOutfile()’:
prog5B.cpp:72: error: expected initializer before ‘.’ token
Thank you to anyone who can help me!
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
using namespace std ;
int openInfile () ;
void openOutfile () ;
void change (string&, string&) ;
int main ()
{
string line, word, diffLine ;
ifstream ins ;
ofstream outs ;
openInfile () ;
openOutfile () ;
change (word, diffLine) ;
while (getline(ins, line))
{
outs << line << endl ;
}
ins.close () ;
outs.close () ;
}
int openInfile ()
{
string fileName ;
cout << "Enter file of madlips outline." << endl ;
cin >> fileName ;
ifstream ins.open(fileName) ;
if (ins.fail (fileName))
{
cerr << "Error: Unable to open file : FILENAME" << endl ;
return -1 ;
}
else
{
openOutfile () ;
}
}
void openOutfile ()
{
string copyFile ;
cout << "Enter name of file for updated data." << endl ;
cin >> copyFile ;
ofstream outs.open(copyFile) ;
}
void change (string&word, string&diffLine)
{
string searchN = "blank-N" ;
string searchA = "blank-A" ;
string searchV = "blank-V" ;
string searchP = "blank-P" ;
string searchD = "blank-D" ;
string noun, adjective, verb, place, adverb ;
if (word == searchN)
{
cout << "Enter a noun." << endl ;
cin >> noun ;
noun = searchN ;
}
else if (word == searchA)
{
cout << "Enter an adjective." << endl ;
cin >> adjective ;
adjective = searchA ;
}
else if (word == searchV)
{
cout << "Enter a verb." << endl ;
cin >> verb ;
verb = searchV ;
}
else if (word == searchP)
{
cout << "Enter a place." << endl ;
cin >> place ;
place = searchP ;
}
else if (word == searchD)
{
cout << "Enter an adverb." << endl ;
cin >> adverb ;
adverb = searchD ;
}
else
{
word = word ;
}
}
What I have tried:
I have adjusted the program many times in regards to the ins and outs.