Hi i need a little help. i want to read a multi array from a file but code blocks said a lots of error and i dont know whats the problem. can u help me?

#include <iostream>
#include <cstdlib>
#include <math.h>
#include <fstream>
#include <sstream>

using namespace std;
int maxn=100;
int maxm=100;

void beolv(string filename, int &n, int &m, int x[maxn][maxm]) {
 //fájl megnyitása
 ifstream fin(filename.c_str(), ios::in);

    fin >> n;
    fin >> m;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            fin >> x[i][j];
        }
    }
 fin.close();

 }
int main()
{
    int n;
    int m;
    int x[maxn][maxm];
    
    beolv("test.txt",n,m,x)
    cout << "" << endl;
    return 0;
}

You must #include<string> to use the string class.

C++ does not allow variable size array - you must make maxn and maxm const

You must put a semi-colon on the end of beolv("test.txt",n,m,x)

thank you :) the missing const was my problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.