Editing Files

Hey everyone. Im trying to do a program that generates junk mail.
I need help editing my file. Please help where you can.
The file 'letter' is the one with the original junk mail but the 'NewLetter' file is the one that must be personalized with the user input.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 #include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>

using namespace std;

 void add_Name(fstream& input, ofstream& output,string  &name)
 {
 //file editing;
    char next_Char;
    int position;
    input.get(next_Char);

    while(!input.eof())
     {
        if(next_Char =='#N#')
        {
//please help here
           output <<name;
        }

      else
         output<<next_Char;
         input.get(next_Char);
     }

 }

int main()
{
   fstream input;
   ofstream output;

   cout<<"Begin editing files \n";
   input.open("letter.dat");
   if(input.fail())
   {
      cout<<"Input file opening failed \n";
      exit(1);
   }

   output.open("NewLetter.dat");
   if(output.fail())
   {
      cout<<"Output file opening failed. \n";
      exit(1);
   }

   string name;
   cout<<"Please insert name: ";
   cin>>name;



//calling of the function above
   add_Name(input,output,name);

   input.close();
   output.close();
   return 0;
}
Topic archived. No new replies allowed.