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.
#include "typeset.h"
#include <string>
#include <sstream>
usingnamespace 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 = "";
}
}
}