title: fopen doesn't open
body: <p>I am using Code::Blocks and have set the command-line arugments via the IDE. I have also opened the executable with the proper argument and I can't manage to get a non-<code>NULL</code> on <code>fopen()</code> return. I've tried hard-coding the filename also with no success. The platform is Windows XP SP3.</p>
  
  <p>The first is the one that fails, when i hardcoded it i used double backlash. Also i never knew if the second works because i never managed to start the process by opening the first one.</p>
  
  <p>Obviously i put the text file in the same directory that the executable and rebuilt the executable many times, but it still doesn't work.</p>
  
  <p>EDIT: I added the perror("fopen"); line in the if(finput==NULL) block. This is the output.</p>
  
  <p><a href="http://prntscr.com/h71pa" rel="nofollow">http://prntscr.com/h71pa</a></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #define first_part_url "[url=http://magiccards.info/query?q="
  #define second_part_url "&amp;v=card&amp;s=cname]"
  #define end_bracket "[/url]\n"
  #define output_file_prefix "output_"
  
  char* get_card(FILE* finput);
  
  int main(int n, char* arguments[])
  {
  FILE* finput;
  FILE* foutput;
  short int counter;
  char* output_filename;
  char* finalstring;
  
  
  for(counter=1; counter&lt;n; counter++)
  {
      finput=fopen(arguments[counter], "r");
  
      if (finput==NULL)
      {
          printf("Unable to open ");
          puts(arguments[counter]);
                      perror("fopen");
          break;
      }
  
      strcpy(output_filename, output_file_prefix);
      strcat(output_filename, arguments[counter]);
  
      if((foutput=fopen(output_filename, "w"))==NULL)
      {
          printf("There was an error while trying to open ");
          puts(arguments[counter]);
          printf(" .\n");
          break;
      }
  
      while(!feof(finput))
      {
      finalstring=get_card(finput);
      fputs(finalstring, foutput);
      while(((fgetc(finput))!='\n')||feof(finput));
      }
  
      printf("Autocarding ");
      puts(arguments[counter]);
      printf(" was a success.\n");
      fclose(foutput);
  }
  
  if(finput!=NULL)
  {
  fclose(finput);
  free(finalstring);
  }
  return 0;
  }
  
  char* get_card(FILE* finput)
  {
  char* currentcard;
  char* finalstring;
  
  currentcard=(char*)malloc(sizeof(char)*150);
  fgets(currentcard, 150, finput);
  
  /* Allocates the exact amount of space needed for the final string*/
  finalstring=(char*)malloc(sizeof(char)*(strlen(first_part_url)+strlen(second_part_url)+strlen(end_bracket)+strlen(currentcard)));
  
  /* Get all the final forum link together*/
  strcat(finalstring, first_part_url);
  strcat(finalstring, currentcard);
  strcat(finalstring, second_part_url);
  strcat(finalstring, end_bracket);
  
  free(currentcard);
  
  return finalstring;
  }
  </code></pre>