Having trouble with a string searching program in C++ : <p>for a homework assignment I have been tasked with creating a program that takes a string that is formatted with all words put together, rather then with spaces, and separates the words.</p>

<p>Somewhat hard to explain, but what I mean is that the string "StopAndSmellTheRoses", must be converted to "Stop and smell the roses", notice how only the first letter of this sentence is capitalized, that is another requirement.</p>

<p>My thoughts are to create a function that searches the string for an uppercase letter using the ASCII code table, and when one is found, I add the letters before that capital letter into a new string. I am using nested loops to try and create this, however I am running into a "DEBUG ASSERTION FAILED!" error message each time.</p>

<p>This is only the beginning of this program that I have written so far, and I feel like my ideas haven't been properly translated into code (I basically mean I have little to no idea how to transfer these ideas into actual code).</p>

<p>So far I have:</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;string&gt;
#include&lt;cctype&gt;
using namespace std;

void strConvert(string);

int main()
{
    string myStr = "StopAndSmellTheRoses";

    strConvert(myStr);

    system("pause");
    return 0;
}

void strConvert(string myStr)
{
    string newStr;
    for (int i = 1; i &lt;= sizeof(myStr); i++)
    {
        if (myStr[i] &gt; 'A' &amp;&amp; myStr[i] &lt; 'Z')
        {
            for (int j = 1; j &lt; i; j++)
            {
                newStr += myStr[j];
            }
            tolower(myStr[i]);
            newStr += '\n';
        }
    }
    cout &lt;&lt; newStr;
}
</code></pre>

<p>I'm not really sure if my method of "adding" the letters of myStr to newStr even works, but it's what i've been playing around with. Could anyone please help me figure out how to get my function to run? I understand I probably have a large amount of errors, please understand i'm new to c++.</p>

<p>Thank you!</p>
