weird error

I was doing a practice problem here and I wrote this code

int main(void)

{

int t=0;

scanf("%d\n",&t);

printf("%d\n",t);

while(t!=0)

{

    char s[]="",j[]="";

    int i=0,c=0;

    scanf("%s",j);

    scanf("%s",s);

    int l=strlen(s);

    for(i=0;i<l;i++)

    {

        if(strchr(j,s[i]))

        c++;

    }

    

    printf("%d %d\n",t,c);

    

    t--;

}

return 0;

}

it is reading the value of t correctly but when it enters the while loop its value changes and the output is like :

4

1717920867 0

1711299137 0

1711300961 0

25966 1

25965 0

25964 0

25963 0

25962 0

25961 0

25960 0

25959 0

25958 0

25957 0

25956 0

25955 0

25954 0

25953 0

25952 0

25951 0

25950 0

25949 0

25948 0

25947 0

25946 0

25945 0

25944 0

25943 0

and so on . Can anyone please help me understand my mistake here.

The error is in this line:

char s[]="",j[]="";

0 length array?
Change to:

char s[100],j[100];
1 Like
//