title: Trying to write to a file
body: <p>I am trying to open and then write to a .dat file. The file is just a simple series of numbers, but i would like to  add to it. Right now the fputs isn't working for me. </p>
  
  <p>I was wondering if I am using the right function to do the job. Right now it says i can't use the integer  <strong>enter_this</strong> in the function <strong>fputs</strong> because it is not a constant character. </p>
  
  <p>I want to ask the user to add a integer to the file. My next step after i understand this is to add strings, floats, characters and more. But just getting something that is working is good. </p>
  
  <p>#define _CRT_SECURE_NO_WARNINGS
      #include 
      #include 
      #include 
      #include 
      #include 
      #include 
      #include 
      #include </p>
  
  <pre><code>//functions called
  
  //why is it void?
  int main(void)
  {
  
      FILE *pFile;
      int choice = 0;
      char buf[40];
      int i = 0;
      int num[40];
      int enter_this;
  
      printf("WELCOME. \n\n");
      pFile = fopen("test.dat", "r");
      if (pFile != NULL)
  
      for (i = 0; i &lt; 8; i++)
      {
          //get num
          fgets(buf, sizeof(buf), pFile);
          num[i] = atoi(buf);
  
          printf("#%i = %i\n", i, num[i]);
      }
  
  
      printf("Enter number to be added: ");
      gets_s(buf);
      enter_this = atoi(buf);
      fputs(enter_this, pFile);
      fclose(pFile);
  
      system("pause");
  
  }//end main
  </code></pre>