dimanche 6 octobre 2019

Arrays declared globally gives out of scope error in functions

I have these arrays declared globally

char str1[] = "6541254939322816220209974565477289648317";
char str2[] = "3142522751761601737419090933147067701840";

int str1_size = strlen(str1);
int str2_size = strlen(str2);

int lcs[str1_size][str2_size];
int arrows[str1_size][str2_size];

But when I access this inside a function, it gives

lcs was not declared in this scope

also

array bound is not an integer constant before ‘]’ token
int lcs[str1_size][str2_size];

What am I doing wrong here ?

Aucun commentaire:

Enregistrer un commentaire