Hi everyone. I have a code script that deleting unused logs.
I have this function for it. +5 represents the days. I want to get it from outside, from a config file. How can i do it?
system("find /var/log -name '*.log' -type f -mtime +5 delete");
Im getting errors
'buff' was not declared in this scope
'days' was not declared in this scope
And it gives me an segmentation fualt error. What can be the reason?
I compile it with g++ in my linux.
It gives me the error : Segmentation fault (core dumped)
Ok. So trace through the code using the debugger. Which line is giving the problem?
What is the value of days after L8? What is the value of req after L10? What are the contents of buff after L13?
> I compile it with g++ in my linux.
> It gives me the error : Segmentation fault (core dumped)
Do you have a file called config?
Does it contain what you want?
Did it open the file correctly?
> 'buff' was not declared in this scope
> 'days' was not declared in this scope
See, I assumed you would know how to fill in the blanks and make the appropriate changes.
It seems though you're looking for copy/paste answers that work out of the box.
@suslucoder, this was just an idea, you're expected to implement it yourself.
The code probably is failing because you don't have a file called "config" that your code can see, and fp has the value NULL.
Thank you for all your answers. I was written my file name wrong...
Sorry for keeping you busy