943,940 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4765
  • C++ RSS
Sep 21st, 2004
0

Create Function that prints letters, words and sentences

Expand Post »
I am in a C++ class and find myself struggling with creating functions that use letters. I have to write out two sentences to the screen. But the assignment is create one function for each letter, space, carriage, return, and punctuation mark. Each word output is controlled by a function (calls each letter, etc function). Each sentence output is controlled by a function (calls each word function). I have read my text book over and over. I have even bought the book C++ for dummies. We have not studied strings or arrays. I know that if I wanted to type out the whole sentence I would have to have code like the following
#include <iostream>

using std::cout;
using std::endl;

//prototype
void Sentence (void);

void main (){
//call
Sentence ();
}

//definition

void Sentence (void){
cout << I need help << endl;
}

So my question is how do I do this a letter at a time and bring it all together using functions to create letters then words and then sentence Any help will be appreciated
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
lakessler1 is offline Offline
2 posts
since Sep 2004
Sep 21st, 2004
0

Re: Create Function that prints letters, words and sentences

From the sounds of it, you'd have a bunch of functions like this:

C++ Syntax (Toggle Plain Text)
  1. void Print_a()
  2. {
  3. printf("a");
  4. }

and then to make the word 'apple' you might have:

C++ Syntax (Toggle Plain Text)
  1. void Print_apple()
  2. {
  3. Print_a();
  4. Print_p();
  5. Print_p();
  6. Print_l();
  7. Print_e();
  8. }

and so on.
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 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: Using printf with a file
Next Thread in C++ Forum Timeline: virus found message when compiling my source code





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


Follow us on Twitter


© 2011 DaniWeb® LLC