Can I have a "little" help in the right way....
Write a program to generate personalized junk mail. The program takes input both from an input file and from the keyboard. The input file contains the text of a letter, except that the name of the recipient is indicated by the three characters #N#. The program asks the user for a name and then writes the letter to a second file but with the three letters #N# replaced by the name. The three-letter string #N# will occur exactly once in the letter.
Hint: Have your program read from the input file until it encounters the three characters #N#, and have it copy what it reads to the output file as it goes. When it encounters the three letter #N#, it then sends output to the screen asking for the name from the keyboard.
this is what I got...
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
int main()
{
using namespace std;
char infile[50], name[50];
ifstream instream;
ofstream outstream;
cout << "Hello!\n";
cout << "Please enter your name: ";
cin >> name;
instream.open("infile.txt");
if (instream.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
outstream.open("outfile.txt");
if (outstream.fail())
{
cout << "Output file opening failed.\n";
exit(1);
}
instream >> "Enter your text: ";
outstream << "Your out stream is" << infile;
instream.close();
outstream.close();
return 0;
}