Deepak and Primes

Segmentation fault in my code but I am not able to recognize it where it is.

refer this

I know the alternate method but I want to know the error in my code.

ok let me debug ur code

The segmentation fault in my code is because of the for loop in main fn. It might helps you.

image
this was the error. u have not declared the vector properly

1 Like


this is ur code. it is working perfectly now

1 Like

image
On gfg vector is initialized in this way so why my initialization is wrong?

image
the use push_back function

1 Like

ohh okay! My doubt is clear Thanks!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.