I am working in C. I'm trying to copy values from one file to another new file minus the first line. Then I am setting the values in the new file to a matrix.
The first file contains:
Matrix1
2 3
1 6
2 4
3 5
I need to find some way to set the integers to int matrix1[4][2].
Is there a better way to do this? This is what I have so far:
When I use this code, all that matrix1[i][j] returns are 0's.
The first file contains:
Matrix1
2 3
1 6
2 4
3 5
I need to find some way to set the integers to int matrix1[4][2].
Is there a better way to do this? This is what I have so far:
Code:
tempFile=fopen("/Users/ITMFL/Desktop/tempFile1.txt","r+"); input1=fopen(inputFile,"r+"); b=1; for (i=0;i<=10;i++) { fgets(cc[i],100,input1); } for (i=b;i<=5;i++) { fputs(cc[i],tempFile); } fclose(tempFile); for (i=0;i<=20;i++) { for (j=0;j<=20;j++) { fscanf(tempFile,"%d",&matrix1[i][j]); printf(" %d ",matrix1[i][j]); } } fclose(tempFile); fclose(input1);
Comment