mercredi 16 novembre 2022

Globally array declaration c++ [closed]

I want to make a global 2d array in c++ and fill that array using memset function of c++.

#include <bits/stdc++.h>
using namespace std;
int t[5][5];
memset(t, -1, sizeof(t));
int main(){
 return 0;
}

Defining the array using memset outside the main function is not working it is giving the error.

prog.cpp:11:7: error: expected constructor, destructor, or type conversion before ( token memset(t, -1, sizeof(t));

What does this error mean and how to solve this?

Aucun commentaire:

Enregistrer un commentaire