Skip to content
Advertisement

Why am I receiving segmentation fault (core dumped)?

This program was created to log the counter every 5 seconds. The while loop needs to be running while the daemon process is running in the background and logging the counter.

The error I’m receiving is: Segmentation fault (core dumped). the terminal ask to input a number, when I input the number I receive the error.

JavaScript

I think the while loop below may be in the wrong place.

JavaScript

Advertisement

Answer

Like kjohri said, you need to pass a pointer to clos in the scanf function

Add an & symbol

JavaScript

Also it looks like you named the variable count, but in the function you wrote counter. Instead write:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement