replacing for loop with while in C : <p>i am trying to make a code that searchs for a "for" loop in the input file, replace it with its "while" equivalent, leaving the rest untouched, and create a new output file with the new code, i need ideas and some help, i dont exactly expect someone else to do it. (remember, there may be another for loop inside a for loop) ex.</p>

<pre><code>for(i=0;i&lt;10;i++) {
    some stuff here;
}
</code></pre>

<p>to</p>

<pre><code>i=0;
while(i&lt;10) {
the exact same stuff here;
i++;
}
</code></pre>

<p>or</p>

<pre><code>for(X;Y;Z) {
K;
}
</code></pre>

<p>to</p>

<pre><code>A;
while(Y) {
K;
Z;
}
</code></pre>
