Timeline for Tips for golfing in C
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 2, 2020 at 14:13 | comment | added | Lundin |
@primo In a conforming program, you are not allowed to change the type of the parameters of main(). You may rename them or use a typedef'd type, but you can't change them. main(char*s,int**a) is a wildly non-portable gcc extension. But on the other hand, K&R style parameters are just as non-portable and no longer standard C.
|
|
Jun 17, 2020 at 9:04 | history | edited | CommunityBot |
Commonmark migration
|
|
Feb 21, 2020 at 10:02 | comment | added | primo |
Quite often I've found that main(char*s,int**a) is the shortest declaration. s=*++a will still work as expected, as sizeof(int*) == sizeof(char*) .
|
|
Jun 14, 2018 at 15:09 | comment | added | Peter Cordes |
@luserdroog: You can use -std=c89 to tell gcc or clang to compile your code according to that older standard, which does allow implicit int with only a warning.
|
|
Jul 13, 2015 at 20:58 | comment | added | luser droog |
@dmckee is right. C99 does not allow implicit int, so you have to use -std=gnu99 and now you're not portable. In clc-speak, you're not even writing "C" code per se, but "Gnu99-C". 'Round here we mostly ignore that, but it's good to mention it if you post code that is compiler-specific. Sometimes people actually do download and execute these programs of ours. :)
|
|
May 17, 2015 at 17:47 | comment | added | dmckee --- ex-moderator kitten | Note that using K&R features and newer (say '99) features together nay or may not be possible. Depends on your compiler. | |
Feb 20, 2015 at 2:43 | history | wiki removed | Doorknob | ||
Oct 24, 2014 at 13:59 | comment | added | Dennis | Apparently this is called K&R style and it precedes ANSI C by a decade. | |
Oct 24, 2014 at 8:41 | comment | added | N. Virgo | Why on Earth does that work?? | |
Oct 24, 2014 at 8:04 | history | answered | feersum | CC BY-SA 3.0 |