So I used a gloabal variable called sample and a structure containing a char.Here is the declaration snippet
So later down the program what happens is when I assign a value to sample it overlaps with d[2].a[0]...before assigning         after assigning
What do I do to fix this? Am I doing something wrong?
Minimal rep:
#include<stdio.h>
#include<stdlib.h>
char sample;
int j=0,level=0,c=0;
struct grid
{
    char a[11];
}d[2];
void set(int level)  //used to initialize the array
{
    j=0;
        for(j=0;j<11;j++)
            if(j!=3&&j!=7)
                d[level].a[j]=' ';
    d[level].a[3]='|';
    d[level].a[7]='|';
    d[level].a[11]=NULL;
}
int main()
{
    set(level++);
    set(level++);
    set(level);
    sample='x';
    printf("%c",d[2].a[0]);
}
It should print space but instead it prints x
 
    