What is the problem with my solution as it is showing runtime error?

#include
using namespace std;

void che(int N, int D, char pr[] , char jb[])
{
int con=0,lock[N]={0};
for(int y=0;y<N;y++)
{
for(int z=0;z<N;z++)
{
if(jb[y]==pr[z] && lock[z]==0)
{
con++;
lock[z]=1;
z=N;
}
}
}
int count=0,cod=0;
for(int i=0;i<N;i++)
{
if(pr[i]!=jb[i])
{
for(int j=0;j<N;j++)
{
if(jb[j]==pr[i])
{
if((i-j)%D==0 || (j-i)%D==0)
{
count++;
}
else
{
cod++;
}
}
}
}
}
if(con!=N)
{
cout<<“No”;
}
else
{
if(cod==0)
{
cout<<“Yes”;
}
else
{
cout<<“No”;
}
}

cout<<"\n";

}
int main()
{
int test;
cin>>test;
for(int x=0;x<test;x++)
{
int n,d;
char p[n],c[n];
cin>>n>>d;
for(int t=0;t<n;t++)
{
cin>>p[t];
}
for(int k=0;k<n;k++)
{
cin>>c[k];
}
che(n,d,p,c);
}
}

You initialised p and c to be of length n before you read n :slight_smile:

[simon@simon-laptop][12:46:44]
[~/devel/hackerrank/otherpeoples]>clang++ -std=c++17 tilwanigaurav8-KOL1504.cpp -O3 -g3 -Wall -Wextra -Wconversion 
tilwanigaurav8-KOL1504.cpp:65:16: warning: variable 'n' is uninitialized when used here [-Wuninitialized]
        char p[n],c[n];
               ^
tilwanigaurav8-KOL1504.cpp:64:14: note: initialize the variable 'n' to silence this warning
        int n,d;
             ^
              = 0
1 warning generated.