why do i get a sigsegv

#include <stdio.h>
int main()
{
long long a[10000],b[100000];
long long d;
for (d=0;d<=1000000000000000;d++)
{
scanf("%d", &a[d]);
if (a[d] = 42)
{
break;
}
else
{
a[d] = b[d];
}
}
for (d=0;d<=10000000000000;d++)
{
if (b[d] = 0)
{
break;
}
else
{
printf("%d", &b[d]);
}}
return 0;
}

Format your code properly or give a link. Regarding SIGSEGV, go through this article.

You probably are coding for TEST.
There are a few corrections I could suggest in your code.

  • You are trying to access a[1000000000000…] where as the array a[] has a size much less than that.
  • a[d]= 42 should be a[d]==42. (though you are not getting SIGSEGV for this).
  • Similarly, b[d]==0 and not b[d]=0.
  • printf("%d",&b[d]); would print the address of b[d]. to print the value, code must be printf("%d",b[d]);
  • you will also have to print a newline after every output you print. as printf("%d\n",b[d]);
  • And most important of all, the pattern you are using to code is not correct. You will have to code it as: input 1 number, check it for equality with 42, and print or abort accordingly. There is no need to store the inputs.

For getting an idea of correct codes to TEST, you can view others accepted submission.
Happy Coding…!!!