In case you ever want to do it the Option 4 way (as suggested in the comments under your post), here is an implementation that will get you started. It was written to use command line values for input file (a CSV) and values for rows and cols. It is partially done allowing you to finish with the final line creation to a header file.
#define DEST "C:\\dir1\\desination.h"
int main(int argc, char *argv[])
{
char *temp = NULL;
int rows, cols;
char linebuf[500]; //accomodates 35 values (and punctuation) per row
if(argc != 4)
{
printf("Usage *.exe <filespec> <n1> <n2> where n1 & n2 are positive integer values.\nHit any key to exit");
getchar();
return 0;
}
rows = strtol(argv[2], &temp, 10);
if (temp == argv[2] || ((rows == LONG_MIN || rows == LONG_MAX) && errno == ERANGE))
{
//handle error
}
cols = strtol(argv[3], &temp, 10);
if (temp == argv[3] || ((cols == LONG_MIN || cols == LONG_MAX) && errno == ERANGE))
{
//handle error
}
//read in rows*cols values from input file into data[]
int data[cols*rows];
FILE *fpin = fopen(argv[1], "r");
if(fpin)
{
char buf[20];
int i=0;
//populate
while(fgets(buf, 20, fpin) && (i < rows*cols))
{
data[i] = strtol(buf, &temp, 10);
if (temp == buf || ((data[i] == LONG_MIN || data[i] == LONG_MAX) && errno == ERANGE))
{
//handle error
}
i++;
}
fclose(fpin);
}
FILE *fpout = fopen(DEST, "w");
if(fpout)
{
// place first line of array in header file:
sprintf(linebuf, "int array[%d][%d] = {\n", rows, cols);
fputs(linebuf, fpout);
// for you to do,
// loop on array data and create "lines" with
// values, commas and "{}" and fputs into fpout
//
}
fclose(fpout); //header file DEST should now be ready to use.
return 0;
}