Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'd add in a NULL pointer check on the result of fopen. Oh, and strcpy must not be used on overlapping memory areas. ^^
-
osmak26yvery good, this program is very well-written.
however, maybe you need to use and learn more about C programming best practices and conventions, for example debugging code usually enabled by using macros, symbols' names don't usually use camel-case (as in c# or c++), and many others
but still very nice -
also don't compare char* with a ==
it usually doesn't do what you expect it to do -
@HampusMa I'm not on Github. Btw., the reason why ctrcpy is not allowed on overlapping memory areas is that it doesn't have to be implemented as bytewise left-to-right copy loop. There are clever implementations which copy e.g. 4 bytes at a time as uint32_t.
And, declaring a static variable in a function and returning its address is possible, but not best practice. It will fail with multithreaded code. Instead, you hand over a buffer pointer to the function as parameter.
That however brings another problem because handing an array to a function loses the size information, so you also hand over a length variable of type size_t. -
@HampusMa I got my solution at home and don't use external services. But, especially for a learning project, you will profit much more from researching yourself than from a ready-made pull request. :-)
-
@kenogo Sorry i didnt know that it was a buildroot specific thing that it didnt show the OS. I use jslinux (which uses buildroot) because im on a ipad (trash technology tbh).
And while it does have the same real time, the user and sys time is lower -
@kenogo nice. And i forgot to say something. I could possibly make it even faster if i remove a bunch of stuff like all the arguments and modes and etc
Related Rants
-
gururaju56*Now that's what I call a Hacker* MOTHER OF ALL AUTOMATIONS This seems a long post. but you will definitely ...
-
linuxxx70This guy at my last internship. A windows fanboy to the fucking max! He was saying how he'd never use anythi...
-
creedasaurus62Another dev on my team just got a new machine. Before he came in today I made two separate USB installers and ...
I finally managed to make my first actual c program.
It's pretty lame but it's atleast something. It tells you what Linux distrobution youre on and that's pretty much it.
Here is it if you would for any reason be interested
https://github.com/Hampusm/...
And btw. C is so fucking hard. ðŸ˜
random
linux
c
github
coding