title: Why does this daxpy not work in c++?
body: <p>I have this code that's suppose to do the daxpy operation of two vectors and output the result, but it gives me 3 4's when I run it (I think it's suppose to give me 3 6's).</p>
  
  <p>I feel as though I'm missing something of key importance about daxpy, but I have no idea what it is.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  
  extern "C"
  {
  
      double daxpy_(double *A, double *B, int *n, double *a);
  //The daxpy fortran function shown above multiplies a first matrix 'A' by a constant 'a'
  //and adds the result to a second matrix 'B.' Both matrices are of size 'n.'
  }
  
  void daxpy(double *A, double *B, int n, double a);
  //The function above is declared in order to utilize c-notation to perform the fortran
  //daxpy function which takes a first matrix 'A' and multiplies the matrix by a costant 'a'
  //and then adds the result to a second matrix 'B.'
  
  int main(int argc, char *argv[])
  {
      double A[3], B[3];
      int n=3;
      double a=1.0;
      for (int i=0;i&lt;3;i++)
      {
          A[i]=2;
          B[i]=4;
      }
      daxpy(A, B, n, a);
      for (int i=0;i&lt;3;i++)
      {
          cout &lt;&lt; B[i] &lt;&lt; endl;
      }
  }
  
  void daxpy(double *A, double *B, int n, double a)
  {
    for (int i=0;i&lt;n;i++)
    {
      B[i]=daxpy_(A, B, &amp;n, &amp;a);
    }
  }
  </code></pre>