title: C - adding to an Char Array and Int
body: <p>Basically, I have an array being passed as a pointer to a function, which capitalizes the first letter, the strlen of that array is also being passed.</p>
  
  <p>What I want to do, after capitalization, is to then append '1' to the end of the array, so that <code>hello</code> becomes <code>Hello1</code>. But I am unsure how to do such thing in code, or whether its possible. </p>
  
  <pre><code>...
  char myString[70];  &lt;-- Array being passed, where the string is never &gt; 64 char's.
  ...
  
  void capFirst(char *s, int i) {
      s[0] = (toupper(s[0]));
  }
  </code></pre>
  
  <p>EDIT: Solutions below do the following:</p>
  
  <pre><code>1Security
  1Sebastian
  1Schumacher
  1Sanderson
  </code></pre>
  
  <p>EDIT:</p>
  
  <pre><code>void capFirst(char *s, int i) {
   s[0] = toupper(s[0]);
   s[i] = 1;
   s[i+1] = '\0';
  }
  
  
  int main(int argc, char** argv) {
  int i;
  int j = 0;
  char fileSave[256];
  char myString[50];
  FILE *fpIn, *fpOut;
  for(i = 1; i &lt; argc; i++) {
      fpIn = fopen(argv[i], "rb");
      snprintf(fileSave, 256, "%s~[%d]", argv[i], i);
      fpOut= fopen(fileSave, "wb");
      while((fgets(myString, 49, fpIn)) != NULL) {
          if(isspace(myString[0]))
              break;
          j = strlen(myString);
          if( (j &gt; 8) &amp;&amp; (j &lt; 64) ) {
              capFirst(myString, strlen(myString));
              fprintf(fpOut, "%s", myString);
          }
      }
  
  }
  return 0;
  }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <pre><code>void capFirstappOne(char *s, int i) {
      s[0] = toupper(s[0]);
      s[i] = '1';
      s[i+1] = '\0';
  }
  
  
  int main(int argc, char** argv) {
  int i; int j = 0;
  char fileSave[256];
  char myString[50];
  FILE *fpIn, *fpOut;
  for(i = 1; i &lt; argc; i++) {
      fpIn = fopen(argv[i], "rb");
      snprintf(fileSave, 256, "%s~[%d]", argv[i], i);
      fpOut= fopen(fileSave, "wb");
      while((fgets(myString, 64, fpIn)) != NULL) {
          j = strlen(myString);
          if (j &gt; 0 &amp;&amp; (myString[j-1] == '\n')) {
              myString[j-1] = '\0';
          }
          if( j &gt; 8) {
              capFirstappOne(myString, strlen(myString));
              fprintf(fpOut, "%s\n", myString);
          }
      }
  
  }
  return 0;
  }
  </code></pre>