| | |
A prayer to the C++ God pleaze help!!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 3
Reputation:
Solved Threads: 0
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;
}
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
- Super Moderator (DaniWeb Community Feedback)
- Collins: Why this scientist believes in God (Geeks' Lounge)
- Evolution: Science vs. Religion (Geeks' Lounge)
- Review my website (Website Reviews)
Other Threads in the C++ Forum
- Previous Thread: decimal > binary > Oct > Hex
- Next Thread: Sound Programming ?? Need your help
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





