10

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. 😠

Comments
  • 6
    I'd add in a NULL pointer check on the result of fopen. Oh, and strcpy must not be used on overlapping memory areas. ^^
  • 0
    @Fast-Nop maybe a pull request?
  • 1
    very 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
  • 0
    also don't compare char* with a ==

    it usually doesn't do what you expect it to do
  • 0
    @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.
  • 0
    Ok. What do you use? Gitlab?
  • 0
    @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. :-)
  • 0
    Screw you i made a actually useful program https://github.com/Hampusm/lo
  • 0
    @kenogo And also. uname doesnt even show you the name of your operating system. And beside that, gld is also faster.
  • 0
    @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
  • 0
    Nice keyboard btw. I dont know how you could possibly write with it though
  • 0
    @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
  • 0
    @kenogo i made a stripped down version and it got a bit faster
Add Comment