I have to do some appending output for a school assignment although was told not to use "ios::app" in the code. Here is the funtion with the ios::app... although I have no idea how to do it otherwise. Any suggestions?
void FindWord(char a[], char b[], int count)
{
//define the ofstream and set the operation to append on output
ofstream outFile;
outFile.open("Output.txt", ios::app);
int k, j;
//find how long the magic words are
for(j=0; b[j] != '\0'; j++);
//check to see if the array contains the magic words and note location
for(int i=0 ; a[i]!='\0' ; i++)
{
k=0;
while(a[i+k] == b[k] && k < j && a[i+k] != '\0')
{
k++
}
if (k==j)
{
//display the where the magic word is found within the line
cout<<"The magic word \""<<b<<"\" is found at column "
<<(i+1)<<" of line "
<<count<<"."<<endl;
outFile<<"The magic word \""<<b<<"\" is found at column "
<<(i+1)<<" of line "
<<count<<"."<<endl;
}
}
}
You can replace ios::app with 8 which is the numeric value of it (see your implementation of xiosbase).
If you want to avoid automatic casting, use (ios::_Openmode)8