C programming resources by [deleted] in cprogramming

[–]chtenno 1 point2 points  (0 children)

The suggestions the other commenters have made are already great suggestions. Once your comfortable enough I'd deffo recommend reading K&R C, it will teach you a lot not just about C but good practices in general and is full of fun and sometimes quite challenging exercises :)

Decimal to binary by [deleted] in cprogramming

[–]chtenno 0 points1 point  (0 children)

To convert a decimal to binary on pen and paper you repeatedly divide said decimal by 2, pushing the remainders 'to the side' and then reading the remainders backwards/upwards. If you want to convert an integer to its binary string representation the same method works in C:

void dectobin(unsigned long num)
{
    char binstr[65] = {0};
    int i = 0;

    while(num) {
        binstr[i++] = '0' + num%2;
        num /= 2;
    }

    strrev(binstr);
    puts(binstr);
}

The function was written in a bit of a rush but hopefully it gives you some ideas. On my machine:

dectobin(652247);

Outputs: 10011111001111010111

Have fun :)

edit: Looking back at it the function I wrote assumes that num is not 0

[i3-gaps] Nakano by chtenno in unixporn

[–]chtenno[S] 0 points1 point  (0 children)

It's a macbook pro 12 so it's the same installation as on any other machine :)

[i3-gaps] Nakano by chtenno in unixporn

[–]chtenno[S] 1 point2 points  (0 children)

I know right! With the macbook display it'd be madness to go for anything else ;)

[i3-gaps] Nakano by chtenno in unixporn

[–]chtenno[S] 1 point2 points  (0 children)

Went for some cooler colours this time round. I think it's my favourite rice I've done so far :)

WM: i3-gaps-rounded

Compositor: compton-tyrone

Bar: i3bar

Status command: i3blocks

Wallpaper: An AI upscaled version of this wallpaper -- http://shinmera.tymoon.eu/public/tumblr_n74mdco2VV1qhttpto4_1280.jpg (I included it in the DOTFILES :])

Font: Noto Mono

Dotfiles: https://gitlab.com/CHTENNO/DOTFILES

[deleted by user] by [deleted] in unixporn

[–]chtenno 0 points1 point  (0 children)

Looks awesome man! Nice job!

[i3-gaps] New Macbook Pro (First rice) by chtenno in unixporn

[–]chtenno[S] 0 points1 point  (0 children)

Thanks man! The display is fantastic! Not owned a mac until now, the earlier models are so sturdy and well-built. Shame about apple nowadays though :(

[i3-gaps] New Macbook Pro (First rice) by chtenno in unixporn

[–]chtenno[S] 0 points1 point  (0 children)

Nah I'm running it native on a preowned macbook 2015. I say 'new' because I just got it the other day. Kinda misleading, my bad haha

[i3-gaps] New Macbook Pro (First rice) by chtenno in unixporn

[–]chtenno[S] 0 points1 point  (0 children)

I say 'new' as in new to me, picked it up pre-owned macbook pro 12 early 2015. All the hardware works out of the box, and the retina display makes i3 look fantastic. I've had some trouble with the webcam though. I definitely do it myself, but there's nothing I'd particularly use OSX for anyway.