×

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

 0 #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

 0 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. answered 30 Jan '15, 23:26 4.2k●5●23●64 accept rate: 15% I am trying to initialize all elements with 0. (30 Jan '15, 23:32) 1 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. (30 Jan '15, 23:41) damn_me3★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,718
×1,911
×1,477
×1,302
×29

question asked: 30 Jan '15, 23:19

question was seen: 1,107 times

last updated: 30 Jan '15, 23:41