title: How do I pass an array(1D) to a function using pointers in C?
body: <p>I am struggling with the last bit of this program, I need to pass the array to two different functions and I can't figure out how to do it.</p>
  
  <p>The only errors I get occur:
  Here:</p>
  
  <pre><code> input(array[20]);
   calculate(array[20],&amp;pairs);
  </code></pre>
  
  <p>and here:</p>
  
  <pre><code>//exit,
  exit;
  </code></pre>
  
  <p>Other than that it should work the way I need it to, I figured out how to use pointers on normal variables but the arrays act differently and I can't figure out what to do... </p>
  
  <p>The documentation is half done and I still have to add the loop at the end that the description outlines, but I just need help with passing the arrays. </p>
  
  <p>Also the error involving my exit line is irrelevant to the question, but if you know a fix that would be great!</p>
  
  <pre><code>/*
  Description: Do not use global variables. Pass your arguments by value and
               by reference. Using arrays and modular programming techniques,
               write a C program that will allow a user to populate an array
               with integers, and then compute and print out the number of
               adjacent pairs in the array (i.e. the number of occurrences where
               an array element is the same as its neighbors). For example, if
               the array contained [2,3,3,4,52,52,4,4,4,4,7,7,1], the number of
               adjacent pairs is 6. The program should give the user the option
               of examining more than one array (i.e. loop). Assume the array has
               a max. of 20 elements. The main() function should primarily be
               responsible to direct the flow of logic.  That is: use one
               function to obtain input (pass by reference), another function to
               do processing (pass by value), and perhaps a third function to do
               output (pass by value).  The main() function should call the input
               function and the processing function. 
  */
  
  //Include statements.
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;math.h&gt;
  
  //Standard namespace.
  using namespace std;
  
  void input (int array[20]); //Used when user inputs the numbers.
  void calculate(int array[20], int *pairs); //Used to calculate the matches.
  void output(int *pairs); //Used to output the number of pairs.
  
  int main(void) 
  { 
       int array[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
       char quit;
  
       start:
       int pairs = 0;
       input(array[20]);
       calculate(array[20],&amp;pairs);
       output(&amp;pairs);
  
       //Ask the user if they want to exit
       printf("\nWould you like to continue testing my project, or exit?");
       printf("\nTo exit input: 'N' or 'n'. To continue testing input anything else.");
       //store their input in variable: exit
       scanf("%s",&amp;quit);
       //If they want to exit...
       if (quit == 'N' || quit == 'n')
       {
           //exit,
           exit;
       }
       //otherwise,
       else
       {
           //clear the screen
           system("cls");
           //and go back to the start.
           goto start;
       }
  }
  
  void input(int array[20])
  {
       int count = 0;
       for (count;count&lt;20;count++)
       {
           printf("Enter values . . . \n");
           scanf("%i", &amp;array[count]);
       }
  }
  
  void calculate(int array[20], int *pairs)
  {
       int counter = 0;
       for (counter;counter&lt;19;counter++)
       {
           if (array[counter] == array[counter+1])
              *pairs+=1;
       }
  }
  
  void output(int *pairs) 
  {
       printf("Number of pairs: [%i]\n", *pairs);
  }
  </code></pre>