>c fags will defend this
C fags will defend this
>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
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.
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
>blog.robertelder.org
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
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