EDN Admin
Well-known member
<br/>
<span class="x_vote-count-post 2<br/>
<a title="This question does not show any research effort; it is unclear or not useful (click again to undo)
down vote http://stackoverflow.com/questions/13432535/how-to-name-and-create-file-in-a-loop#" title="This is a favorite question (click again to undo)
favorite
In C, I want to create and open text files to write data into, but the problem is I want to name the files on the go, such as
<pre class="lang-c prettyprint prettyprinted
[/code]
such that I will create file 0.txt, 1.txt, 2.txt ... 999.txt.
How is this possible? I checked open and rename functions, but couldnt find a way to do.
Thank you so much for all your help.<br/>
Best,
View the full article
<span class="x_vote-count-post 2<br/>
<a title="This question does not show any research effort; it is unclear or not useful (click again to undo)
down vote http://stackoverflow.com/questions/13432535/how-to-name-and-create-file-in-a-loop#" title="This is a favorite question (click again to undo)
favorite
In C, I want to create and open text files to write data into, but the problem is I want to name the files on the go, such as
<pre class="lang-c prettyprint prettyprinted
Code:
<span class="typ FILE<span class="pln <span class="pun *<span class="pln ptr<span class="pun ;<span class="pln
<span class="kwd for<span class="pun (<span class="pln i<span class="pun =<span class="lit 0<span class="pun ;<span class="pln i<span class="pun <<span class="lit 1000<span class="pun ;<span class="pln i<span class="pun ++){<span class="pln
fopen_s<span class="pun (&<span class="pln ptr<span class="pun ,<span class="str "i.txt"<span class="pun ,<span class="str "w"<span class="pun );<span class="pln
operations to fill data into file i<span class="pun .<span class="pln txt<span class="pun ;<span class="pln
fclose<span class="pun (<span class="pln ptr<span class="pun );<span class="pln
<span class="pun }
such that I will create file 0.txt, 1.txt, 2.txt ... 999.txt.
How is this possible? I checked open and rename functions, but couldnt find a way to do.
Thank you so much for all your help.<br/>
Best,
View the full article