C fags will defend this

>c fags will defend this

Attached: DY15SQvWkAUUQl1.jpg (676x530, 39K)

Other urls found in this thread:

blog.robertelder.org/switch-statements-statement-expressions/
blog.robertelder.org/fast-meme-transform/
clifford.at/cfun/cliffdev/
twitter.com/NSFWRedditVideo

>brainlet

This isn't even valid code.

#include

int main(int argc) {
char *num;

switch(argc-1) {
if (0) {case 0: num = "Zero";}
if (0) {case 1: num = "Two";}
printf("%s\n", num);
break;
case 2:
printf("One\n");
}

return 0;
}

You can assign a char* to a char const

lel I switched One and Two, but anyway, this code compiles, you should try it out.

Why would you write it like that?

People should read this to understand C a bit better.
blog.robertelder.org/switch-statements-statement-expressions/

Attached: Screenshot from 2017-02-13 21-02-03.png (242x243, 88K)

char const *arr[] = {"zero", "one", "two", "three", "four", "five", "many"};
int count = argc < 7 ? 7 : argc;
--count;
puts(arr[count]);

the fuck is the point of the if (0)

for coolness factor

ensures that none of the cases are executed. it's like a more efficent way of commenting out lines in a switch statement

Stop writing bad code.

Attached: Large_helical_device_shot.gif (352x240, 1.04M)

this is still wrong

send(to, from, count)
register short *to, *from;
register count;
{
register n = (count + 7) / 8;
switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while (--n > 0);
}
}

>argc > 7

still not there kid, your getting close though

Attached: pepe84.jpg (420x420, 20K)

>blog.robertelder.org/fast-meme-transform/
I like this guy.

your wrong

no

prove it

Holy fucking shit kill yourself
#include

void main(int argc, char* argv[])
{
printf("Number of arguments passed %d\n", argc);
}

Is it that hard.

How would you do think in Rust then?

too bad register variables get ignored most of the time nowadays :(

You can just use inline Assembly though?

yeah it works fine, i made you double check though lol B U S T E D

Attached: dabbed on.png (553x400, 55K)

It means only one of the `num = "..."` lines are executed, without just using `break;`, so that execution falls through to the printf statement for all those cases. The first one around "zero" is redundant though.

fn main() {
let args : Vec = std::env::args().collect();
println!("Called with {} arguments.", args.len());
}

Technically, shouldn't it be argc -1 if you wanted to count the number of arguments passed to the program, since the name of the program you're running is counted as an argument itself. Or at least it has been every time i've written C (argv[0] == name of the program, argv[1]..argv[n] == the parameters you are passing to the program)

meanwhile scheme fags will defend this
(let* ((yin
((lambda (cc) (display #\@) cc) (call-with-current-continuation (lambda (c) c))))
(yang
((lambda (cc) (display #\*) cc) (call-with-current-continuation (lambda (c) c)))))
(yin yang))

fn main() {
println!("{}", std::env::args().count());
}

No.

This is actually sensible, what is your problem?

Ah I forgot you could do that too, seems like I still have to work on my knowledge of Rust

That's why I love Go's inverted switch-case behaviour: cases break automatically unless you use the "fallthrough" keyword.

wrong

Of course D does it better.

import std.stdio;

void main(string[] args)
{
writeln(args.length, " arguments");
}

>if (0)

>Not getting the purpose

From
clifford.at/cfun/cliffdev/