title: File I/O management in C
body: <p>My first post :), am starting out with C language as basic learning step into programming arena. I am using following code which reads string from text file, makes directory with that string name and opens a file for writing in that created directory. But am not able to create a file inside directory made, here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;direct.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
      char file_name[25], cwd[100];
      FILE *fp, *op;
  
      fp = fopen("myfile.txt", "r");
  
      if (fp == NULL)
      {
          perror("Error while opening the file.\n");
          exit(EXIT_FAILURE);
      }
  
      fgets(file_name, 25, fp);
  
      _mkdir(file_name);
  
         if (_getcwd(cwd,sizeof(cwd)) != 0) 
      {
        fprintf(stdout, "Your dir name: %s\\%s\n", cwd,file_name);
  
          op = fopen("cwd\\file_name\\mynewfile.txt","w");
          fclose(op);
      }
      fclose(fp);
      return 0;
  }
  </code></pre>