hi,
I have created a calculator in C project for managing the tables ( 2-dimensional) which does addition,multiplication.But when I block (recovery of values to store in the matrix) it because I want to load the array from external text files. (I do not know if I am very clear ...)
Here is the code for more info:
Code:
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# define COLUMNS 10
# define LINES 10
int main (int argc, char * argv [])
(
FILE * file = NULL;
int character = 0, i = 0, j = 0;
int table [LINES] [COLUMNS];
for (i = 0; i <LINES; i + +)
(
for (j = 0 j <COLUMNS; j + +)
(
table [i] [j] ='0 ';
)
)
file = fopen ( "tableau.txt", "r");
if (file! = NULL)
(
/ / Loop reading characters one at a
do
(
character = fgetc (file); / / On the bed
if (character! = '|')
(
table [j] [i] = character;
)
else
(
i + +;
)
if (character! = 'n')
(
table [j] [i] = character;
)
else
(
table [j] [i - 1] = table [j] [i];
j + +;
i = 0;
)
printf ( "% c", character) / * and displays the character (compare it: D) * /
) While (character! = EOF)
for (i = 0; i <COLUMNS; i + +)
(
for (j = 0 j <LINES; j + +)
(
printf ( "% ld \ n", table [j] [i]); / * Display the matrix plant ...*/
)
)
fclose (file);
)
system ( "PAUSE");
return 0;
)
Here's my file structure table.txt:
Citation: Matrix
1 | 1 | 1 | 1
2 | 2 | 2 | 2
3 | 3 | 3 | 3
4 | 4 | 4 | 4
The file must be binary?
Bookmarks