C++ Word Program Help!

First of all, this is not schoolwork but rather me trying to read about c++ and through program examples and see if I can write my own. So help is much appreciated if you could as I am a new learner.

This program that I am writing is supposed to look through words in a paragraph and if it fits the equation it adds it to the string otherwise the program resets.

I have written a pseudo-code for this program. Now I am trying to implement what I wrote into c++ code form. I am new to programming and forgot how to implement what I wrote in the two while loops to c++ form: // Fill words into string; // read first character; and 2nd while loop: // Add the character to the string of the word; // Read next character; This is only one of the .cpp files not including main or header files. If you would like to see them to understand more of the program I can attach them as well.


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
#include "typeset.h"
#include <string>
#include <sstream>
 
using namespace std;
 
void typeset (int maxWidth, istream& documentIn)
{
  string line;
  string word;
  string w;
  // Collect Input;
  // Fill maxWidth into W;
  // Read Input;
 
     while (!documentIn.eof())
     {
       // Fill words into string;
      //   read first character;
	 while(!" ")
	  {
	  //  Add the character to the string of the word;
	  //  Read next character;
	  }
	if('\n')
	{
       //print out line and endl;
       cout << line << endl;
	}
       // Check if line is too long;
	      if (line+word+" " < w)
	      {
              line = line + word+ " ";
	      }
       // Output;
          else
          {
          //    Print line an endl;
          cout << line << endl << endl;
          //    Reset line to empty string;
          line = "";
          }
     }
}
Topic archived. No new replies allowed.