this post was submitted on 27 Feb 2026
10 points (91.7% liked)

Programming

25806 readers
102 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

I am trying to write my own string.h functions, my library currently have no dependicies and 11 functions completed. Has basic and readable code to understand. Small binary size. Freely distributable with BSD-3-Clause license. Have a look: mstrutils

top 7 comments
sorted by: hot top controversial new old
[–] tocano@piefed.social 4 points 18 hours ago (1 children)

It's cool to rewrite simple libraries to understand how code works at lower levels.

What style of formatting are you using? It seems peculiar at times.

[–] tafabey@programming.dev 0 points 18 hours ago (1 children)

Thanks for comment. I am using K&R style.

[–] palordrolap@fedia.io 2 points 15 hours ago (1 children)

I'm not sure that's K&R style. In various places you have things where the thing that follows a for, while or if isn't indented, and as far as I'm aware, K&R indents religiously. K&R omits braces on single statements, sure, but that statement is nonetheless indented from the parent keyword.

e.g. you have things like:

while (condition)
statement;

and

for(x;y;z) {
if (condition) {
    statement1;
    statement2;
}
}

Which I'm pretty sure should be:

while (condition)
    statement;

and

for(x;y;z) {
    if (condition) {
        statement1;
        statement2;
    }
}

respectively. The idea is that you can theoretically trace the keyword down to its closing brace, assuming there is one.

[–] tafabey@programming.dev 3 points 14 hours ago* (last edited 14 hours ago)

I didn't notice, it wasn't conscious. Thanks for the heads up. I fixed the indentation

[–] MonkderVierte@lemmy.zip 2 points 19 hours ago* (last edited 19 hours ago) (1 children)

Maybe add some context to the readme, what string.h does or is used for.

[–] tafabey@programming.dev 1 points 19 hours ago (1 children)

Thanks, I've just updated the README with a 'What is string.h?' section

[–] MonkderVierte@lemmy.zip 2 points 19 hours ago

Ohh, seems interesting. Not a C programmer, but still, thanks!