This code works fine on my system . Why is judge showing compilation error on line 8 ?

help
c
c-plus-plus
compilation
java

#1

#include
using namespace std;

int main(){
int t,in,tmp,a[100005],i,j=0,n,c,count;
cin>>t;
while(t--){
	a[100005]={0}; //this is line 8
	cin>>in;
	n=0;
	while(in!=0){
	 tmp=in%10;
		a[j]=tmp;
		j++;n++;
		in/=10;
		
}

count=0;c=0;
for(i=0;i<n;i++){

	if(a*!=c){
		count++;
		c=a*;
	}
	//if(a*==1)
	//count++;
}
cout<<count+1<<endl;}
return 0;

}


#2

What are you trying to do in line 8?

If you are trying to initialize all array elements to 0, you should use a loop (or some other way), as the syntax you are using is wrong.

For all assignments, a[index] refers to a single element.

a[100005] = 0;

will get you past syntax error. But, that is accessing memory outside of allocated locations.


#3

I am trying to initialize all elements with 0.


#4

That is not the correct syntax then, do int a[10000]={0}, doing a[1000]=0 refers to the 999th element of array, not the whole array. Such initialization which you are doing is only valid at the time of declaration.