Formatting text in C : <p>I need an advice on how to handle this task.
I would like to format chars so that only a given number of characters were on one line. User input would be the number representing the max length of the line. The program would then print the char formatted in a way that words are divided by only one space and when some word doesn't fit in the line anymore, it would be printed on a new line.
Example:</p>

<pre><code>char text="Lorem      ipsum dolor sit amet, consectetuer adipiscing elit. Integer metus";
format(text,20);
</code></pre>

<p>Expected output:</p>

<pre><code>Lorem ipsum dolor
sit amet,
consectetuer
adipiscing elit.
Integer metus
</code></pre>

<p>What's the easiest way to do this?</p>
