Count the file matrix



  • code Like, as long as I've been watching, the code's right. sin for the introduction of size from the keyboard removes the matrix filled with zeros When I added

    if(fp==NULL)
    {
       puts("Open file error");
       return;
    }
    

    "Open file error."

    Please tell me what the problem is.

    printf("Введите количество строк матрицы А ");
    scanf("%d", &m);
    printf("Введите количество столбцов матрицы А ");
    scanf("%d", &n);
    

    float A[m][n];

    FILE* fp;
    fp = fopen("matrixA.txt", "rt");

    if (fp == NULL)
    {
    puts("Open file error");
    return;
    }

    for (i = 0; i < m; i++)
    {
    for (j = 0; j < n; j++)
    {
    fscanf(fp, "%f ", &A[i][j]);
    }
    }

    printf("\nМатрица А \n");

    for (i = 0; i < m; i++)
    {
    for (j = 0; j < n; j++)
    {
    printf("%f\t", A[i][j]);
    }

    printf("\n");
    

    }

    fclose(fp);



  • The problem is, you don't open the file. matrixA.txt♪ He's probably just gone. current cataloguefrom which your program is launched.

    The fact that there wasn't a report earlier doesn't mean that everything was good-- just the program didn't complain that it was really bad... :




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2