this post was submitted on 17 Aug 2026
7 points (88.9% liked)
C Programming Language
1341 readers
16 users here now
Welcome to the C community!
C is quirky, flawed, and an enormous success.
... When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd.
... The only way to learn a new programming language is by writing programs in it.
- irc: #c
๐ https://en.cppreference.com/w/c
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I'll attempt to give a more hand wavey approach, but one that is hopefully easier to understand.
First, implement:
Now this can be used in a loop, where you supply a slice starting at the last line (or the beginning of the slice, on the first iteration), where len is the length of the original string minus the amount of characters consumed (index of the beginning of the slice, relative to the start of the original string).
Note this requires calculating the string length beforehand, if this is a c-string (as in null terminated).
This should be relatively simpler to understand and implement than what the standard library supplies, sadly the C standard library is not easy to use or very reliable, so you'll mostly have to make do yourself.
I hope this helped, I'm currently away from a computer so i can't give a code example, good luck.