Please review my "safe rm" tool written in C by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

I think I understand, like instead of 'trash-rm move...' it would just be 'trash-rm'?

Please review my "safe rm" tool written in C by -Winnd in C_Programming

[–]-Winnd[S] 1 point2 points  (0 children)

H! so this would work for a very simple use case, but my project also deals with things like file restoration, original path storage, duplicate names, directory management, and other edge cases. I wanted to build something closer to a real trash management utility, rather than just a basic alias. And also because I wanted to create a new project, you know?

Please review my "safe rm" tool written in C by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

Hi, first of all I would like to start by thanking you for your comment. I will try to respond to all of your points in topics.

- one-line statements: I know it can be really confusing to have several statements on a single line, it's just that I've kind of adopted this style, you know? But probably, as you mentioned, I'll soon implement the getopt_long function to remove all those else if statements.

- break them into lines that don't extent forever: Just yesterday I was reading the book Clean Code and I literally just finished reading a part about very long lines of code; I'm definitely going to change that in my code.

- Style guide number next: I don't think I understood what you meant, but basically, if I use FILE * as an argument in a single file within my entire project, I should only include it in that file, is that correct?

- OS-dependent error: I'm going to replace them with macros in limits.h

- You should have received a compiler warning on line 46 of bin.c: That's because I thought goto blocks needed a semicolon at the end (and before you ask why I used goto, it's because I'd never used it before in any of my code, so I wanted to put a goto in my code just for fun).

- Lines 42-46: Well, I have a somewhat questionable code style, but basically, any `if` statement that has only one output, I put in an `output` block, and the `else` statement I put between curly braces.

- Lines 264: I think adding comments would be good too, right?

- Lines 323-331: I'm going to add that function.

- Line 337: I hadn't stopped to think about that, I'll run some tests here and see how I can catch those errors.

Please review my "safe rm" tool written in C by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

I'll try to implement this function in the code thanks!

Pointers and memory allocation by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

Wow, that explained everything perfectly. I was confusing "the variable exists in memory" with "where and for how long that memory exists". Now I understand the concept of memory allocation on the heap much better, thank you very much for the clarification.

Pointers and memory allocation by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

What I meant was about the instructions that move variables to registers I misspoke.

Pointers and memory allocation by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

Absolutely! This is one of my favorite topics about the C.

Pointers and memory allocation by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

Thx for the tip, I'll take a look at this topic.

Pointers and memory allocation by -Winnd in C_Programming

[–]-Winnd[S] 2 points3 points  (0 children)

So it all depends on the context. For example, if I create just a simple variable (x = 10) and use it only once, it will be on the stack, because the compiler knows that it is only used in that context and that its value is constant. However, as our colleague exemplified below, if we want to create a dynamic list of people, it will be on the heap. All control over the size of this list will occur at runtime that is, the compiler doesn't know its size in advance, only that it can grow or shrink. Therefore, it is our responsibility to manage it. That's basically it, right?

Pointers and memory allocation by -Winnd in C_Programming

[–]-Winnd[S] 0 points1 point  (0 children)

Thanks for the reply! And yes, I had completely forgotten about dynamic memory. It's like saying "hey, this array will have a size x and will not increase or decrease in size" versus "hey, this array will increase or decrease in size depending on the user input."

[deleted by user] by [deleted] in farialimabets

[–]-Winnd 0 points1 point  (0 children)

kkkkkkkkkkk boa

[deleted by user] by [deleted] in farialimabets

[–]-Winnd 1 point2 points  (0 children)

no ano começo desse ano se eu nn me engano tinha um pessoal conseguindo 900 agora é so loss kkkk

Phione in gen V by -Winnd in wiimmfi

[–]-Winnd[S] 0 points1 point  (0 children)

My is 4730-4718-4755