title: How to dynamically change filename while writing in a loop?
body: <p>I would like to do something like this: In a loop, first iteration write some content into a file named file0.txt, second iteration file1.txt and so on, just increase the number.</p>
  
  <pre><code>FILE *img;
  int k = 0;
  while (true)
  {
              // here we get some data into variable data
  
      file = fopen("file.txt", "wb");
      fwrite (data, 1, strlen(data) , file);
      fclose(file );
  
      k++;
  
              // here we check some condition so we can return from the loop
  }
  </code></pre>