944,027 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2592
  • C++ RSS
Sep 8th, 2004
0

A prayer to the C++ God pleaze help!!

Expand Post »
Dear God,

I've been trying to write this program that is suppose to read in a text file manipulate in and give the following out put infact here is the question

Implement a program that uses a form-letter template to generate form letters. Your program should read in a form-letter template from a file. The form-letter template has "holes" in it that are to be filled in with user-entered values. The holes are represented by a pair of @ signs. For example, suppose this is read in from a form-letter template file:

Congratulations, @@! You've just won @@!
To collect, please send $100 to

And suppose the user enters these two values for the two @@ holes:

Raheel Azhar
a new house

Your program should then print this form letter:

Congratulations, Raheel Azhar! You've just won a new house!
To collect, please send $100 to


this is what i have so far but all i get is compilation errors

#include <iostream>
#include <string>



using namespace std;

class FormLetter
{
public:
string letterTemplate;

FormLetter::FormLetter(string fname)
{

letterTemplate = fname;

letterTemplate.open("letterTemplate");
letterTemplate.close();

}

//private:
void generateLetter();
};



void FormLetter::generateLetter()
{
string input;
int count = 0;
++count;
while(count <4)
{
getline(letterTemplate,'@');
cout << "Enter insertion text: " << endl;
cin >> input << endl;
letterTemplate.insert(find_first_of '@', input);
generateLetter();
cout << letterTemplate << endl;

}
}

int main()
{
FormLetter formLetter1("letterTemplate.txt");
formLetter1.generateLetter();
return 0;
}
Similar Threads
Reputation Points: 12
Solved Threads: 0
Newbie Poster
damionspencer is offline Offline
3 posts
since Sep 2004
Sep 13th, 2004
0

Re: A prayer to the C++ God pleaze help!!

letterTemplate.open("letterTemplate");
letterTemplate.close();

letterTemplate is of type string .Do it have open and close methods?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
soniprafull is offline Offline
5 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: decimal > binary > Oct > Hex
Next Thread in C++ Forum Timeline: Sound Programming ?? Need your help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC