I'm working on a program in which overwriting a part of a 2D array with a 1D string is a necessity for the algorithm.
The part that is supposed to do the overwriting is as follows:
char twoD[MAX][MAX];
int top=2;
int main(){
char arr[MAX];
func(arr);
}
void func(char newArr[]){
strcpy(twoD[++top], newArr);
}
Where twoD
and top
are variables that are global variables.
Whenever the program reaches this part, it crashes.