I have a set of data(integer values) in excel stored on my desktop and the format and the full path is "C:\Documents and Settings\USER\Desktop\data.xls" I'm trying to read it and store in an array, but it's not working please can you figure out what's wrong with my code?
Code:#include<stdlib.h>
#include<stdio.h>
main(){
int rows =6;
int cols=6;
int i,j;
int a[rows][cols];
FILE *infile;
infile=fopen("C:\Documents and Settings\USER\Desktop\data.xls", "r");
for(i=0; i<rows; i++)
{
for(j=0; j<cols; j++)
{
fscanf(infile, "%lf", &a[i][j]);
}
}
if ((infile=infile=fopen("C:\Documents and Settings\USER\Desktop\data.xls", "r"))== NULL)
{
printf("Cannot open file. \n");
exit(1);
}
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
printf("%f\t", a[i][j]);
printf("\n");
}