this post was submitted on 25 Aug 2023
391 points (100.0% liked)

Programmer Humor

855 readers
7 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 17 comments
sorted by: hot top controversial new old
[–] JuxtaposedJaguar@lemmy.ml 41 points 1 year ago

Reminds me of lolcode:

HAI 1.2
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
    AWSUM THX
        VISIBLE FILE
    O NOES
        INVISIBLE "ERROR!"
KTHXBYE
[–] Lilium@lemmy.blahaj.zone 29 points 1 year ago

Artistry, on god frfr πŸ™πŸ™

[–] grue@lemmy.ml 18 points 1 year ago (1 children)

Pro tip: the arguments to main() don't have to be named argc and argv.

Also, you forgot to #define an alias for atoi, and number, n, and i could've been named something more on fleek.

[–] bronzle@lemm.ee 5 points 1 year ago* (last edited 1 year ago)

Also could have takin out mains return type and used sus chief

[–] MrNoodleBox@lemm.ee 15 points 1 year ago

Reminds me of Rockstar. The example also implements Fizz Buzz.

[–] db2@sopuli.xyz 14 points 1 year ago* (last edited 1 year ago) (2 children)

Does it make me a bad person that I like this?

Edit: wait.. return ! 0 ; wtf

Edit 2: idc still like it frfr no cap

[–] grue@lemmy.ml 4 points 1 year ago (1 children)

Edit: wait… return ! 0 ; wtf

I mean, returning non-zero exit status on error is just good practice. It even managed to evaluate to the same numerical value as EXIT_FAILURE when I tested it on my machine (gcc 11.4.0 linux x86-64), although I'm not sure if that's always the case or if it's undefined behavior.

This cursed code is quite well-written.

[–] bronzle@lemm.ee 3 points 1 year ago

!0 is defined as 1, that’s how argv [ no cap ] works, that and the ridiculous argc check stood out as a bit off, but works

[–] bronzle@lemm.ee 13 points 1 year ago* (last edited 1 year ago)

For those curious:

int main(int argc, char **argv) {
  if ( -- argc != ! 0 ) {
    errx ( ! 0 , "shheiiiit" ) ;
    return ! 0 ;
  }
  
  int number = atoi ( argv[! 0] ) ;

  for ( int i = ! 0 ; i <= number ; ++ i ) {
    printf ( "%3d " , i) ;
    
    if ( i % 3 == 0 ) {
      printf ( "fizz" ) ;
    }
  
    if ( i % 5 == 0 ) {
      printf ( "buzz" ) ;
    }
    printf ( "\n" ) ;
  }
  return 0 ;
}
[–] NegativeLookBehind@kbin.social 13 points 1 year ago (1 children)
[–] gpw@lemmy.ml 15 points 1 year ago

The path to salvation is filled with terrors and temptation

no cap

[–] RickyRigatoni@lemmy.ml 9 points 1 year ago (1 children)
[–] Zucca@sopuli.xyz 4 points 1 year ago

I'm not a C programmer (is this code even C?), but I anticipated seeing comments like this. πŸ˜‚

It's like watching a car crash in slow motion trying to read it. I can't look away...

[–] Jax@kbin.social 7 points 1 year ago

I was going to suggest ALL CAPS in response, but then I remembered COBOL already exists.

[–] Stinkypete@lemmy.ml 6 points 1 year ago

I'm dumb . does the program do anything?