Read file array [closed]

1

I want to make a program that reads an array from a .txt file and stores the values in an array of the program, but the program is always printing the number 2.

#include <stdio.h>
#include <stdlib.h>



void main(){
    int matriz[10][10];
    int i, j, test;
    FILE *arq;
    arq = fopen("matriz.txt","r");
    if(arq = NULL)
    {
        printf("\nArquivo inexistente.");
        return;
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            fscanf(arq,"%d",&test);
            if(test < 101 && test > 0)//verificar se são numeros
            {
                matriz[i][j] = test;
            }else{//se tiver espaço o contador diminui para não mudar
                i--;
                j--;
            }
        }
    }
    for(i=0;i<10;i++)
    {
        printf("\n");
        for(j=0;j<10;j++)
        {
            printf("%d ",matriz[i][j]);
        }
    }
}

These are the data from the file

 22   18   29   67   59   12   51   92   10   80
 43   20   68    2    7   41   37   17   71   11
  5   50   35   23   63   45   26   84   85   52
 82   48   47   87   19   27   15   34   61   56
 36   79   32   33   25   54    3   58   99   69
 53   64    1   98   14    8   89   72   73   46
 88   57    6   42   24    9   49   78   30   13
  4   39   86   65   62   38   75   77   96   55
 93   16   97   95   60   83   81   28   70   31
 44   76   74   21   94   66  100   90   40   91
    
asked by anonymous 02.02.2018 / 20:58

0 answers