title: converting a string (containing numbers) into an integer and returning that integer
body: <p>i'm working on a code right now in C++, in which i'm supposed to make a function which receives a string of numbers and converts it into an integer then returns that value. for example if i pass "4569" as string, it will return 4569 integer value.
  can anyone help me point out where i'm wrong ??? thanks in advance :)</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  using namespace std;
  
  void getInput(char arr[] , int size )
  {
      cout&lt;&lt;"ENTER THE ARRAY"&lt;&lt;endl;
      cin.getline(arr,size);
  
  }
  
  int stringToInteger(char source[])
  {
      int sum = 0;
      int y=strlen(source);
      int multiply = 1;
      for( int i=y ; i&gt;=0 ; i--)
      {
          int n= source[i];
          sum = (sum + (n * multiply));
          multiply = (multiply *10);
      }
      return sum;
  }
  
  int main()
  {
      const int size =100;
      char inputArr [size];
      getInput (inputArr, size );
  
      int x = stringToInteger (inputArr );
      cout&lt;&lt;"THE RETURNED INTEGER VALUE IS"&lt;&lt;endl;
      cout&lt;&lt;x&lt;&lt;endl;
      return 0;
  }
  </code></pre>