title: How to pass commandline arguments to C function
body: <p>I'm attemting to clean up my code by adding functions and i've come across something I can't seem to figure out.  I have, what I think, is mostly correct code, it runs without the functions I'm trying to implement.</p>
  
  <p>Anyways, my main method takes 4 arguments, the command itself, two inputs and one output.</p>
  
  <pre><code>       int main (int numFiles, char *filenames[]){
  </code></pre>
  
  <p>I have two functions and two structs</p>
  
  <pre><code>    int compareNames(struct Strings,struct Files);
      int fileAssignment(int numFiles, char arraypointer[], struct Files);
  
      struct Files Data;
      struct Strings inputData;
  </code></pre>
  
  <p>i'm having problems passing the char *filenames[] into my functions</p>
  
  <pre><code>    fileAssignment(numFiles, *filenames, Data);    // *filenames is the problem
  </code></pre>
  
  <p>the functions looks like this.</p>
  
  <pre><code>    int fileAssignment(int arguments, char array[],struct Files Data)  // 2ed argument
      {
  
  if ( arguments !=4 ){
  printf(" Need two input files and one output file.");
  return 4;
  }
  
  if ( (Data.input_file1 = fopen (array[1], "r")) == NULL ) {
  printf("Can't open file 1 for reading, it either doesn't exist, or 
      was typed incorrectly.");
  return 1;
  </code></pre>
  
  <p>The code won't compile this block.  something with the array[i] being a pointer cast as an int.  I will gladly post all the code if someone wants to tinker around with it.  I'm thinking my problem is passing the array correctly then calling it correctly.  Not sure, any ideas?</p>