title: getchar() doesn't work well?
body: <p>I wrote this code in C++, and I used <a href="http://en.cppreference.com/w/cpp/io/c/getchar" rel="nofollow"><code>getchar()</code></a> to puase the console, but I did not see any effect of using that function, here is the code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;stdio.h&gt;//to pause console screen
  
  using namespace std;
  //function prototypes
  int  getSmallest(int*);
  int getOccurrence(int, int*);
  
  int main(){
  
      int a[7], counter=0, smallest;
      cout&lt;&lt;"Please enter 7 integers"&lt;&lt;endl;
      while(counter!=7){
          cin&gt;&gt;a[counter];
          counter++;
      }
      smallest=getSmallest(a);
      cout&lt;&lt;"The smallest number is "&lt;&lt;smallest&lt;&lt;"; it apears "&lt;&lt;getOccurrence(smallest,a)&lt;&lt;" times"&lt;&lt;endl;
      getchar();//to pause console screen
      return 0;
  }
  
  int  getSmallest(int*x){
  int count=0, smallest=*x;
  //loop till last item in array
  while(count!=7){
  
      if(*x&lt;smallest)
          smallest=*x;
      count++;
      x++;
  }
  return smallest;
  }
  
  
  int getOccurrence(int smallest, int* address){
  
  int count=0,occ=0;
  //loop till last item in array
  while(count!=7){
  
      if(*address==smallest)
      occ++;
      count++;
      address++;
  }
  return occ;
  
  }
  </code></pre>