I wrote a simple program about calculate the covariance. The data is read from a txt file and coverted to a matrix. and then the covariance is calculated by function calcov().
The warning deprecated conversion from string constant to char [-Wwrite-strings]
is occured for the line printmatrix("cov.txt",cov);. I checked similar question here, but I still can not find where I go wrong, so I post it. I hope I can figure it out.
void calCov(gsl_matrix* data,gsl_matrix* cov,int p)
{
  for(int i=0;i<p;i++){
    for(int j=0;j<p;j++){
      gsl_vector_view a = gsl_matrix_column (data, i);
      gsl_vector_view b = gsl_matrix_column (data, j);
      gsl_matrix_set(cov,i,j,gsl_stats_covariance(a.vector.data, a.vector.stride,b.vector.data, b.vector.stride, a.vector.size));
    }
  }
}
int main()
{
  int n = 158; //sample size
  int p = 51; //number of variables
  int i;
  char datafilename[] = "erdata.txt";
  //allocate the data matrix
  gsl_matrix* data = gsl_matrix_alloc(n, p);
  //read the data
  FILE* datafile = fopen(datafilename, "r");
  fclose(datafile);
  gsl_matrix* cov = gsl_matrix_alloc(p, p);
  calCov(data,cov,p);
  printmatrix("cov.txt",cov);}
 
     
    