Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

75%
+4 −0
Challenges Reverse an ASCII string

C (gcc), 62 bytes main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);} This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, si...

posted 4y ago by Lundin‭  ·  edited 3y ago by Lundin‭

Answer
#4: Post edited by user avatar Lundin‭ · 2021-09-09T10:17:58Z (over 3 years ago)
  • # C (gcc), 62 bytes
  • main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}
  • This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.
  • ---
  • Revisited, function-based equivalent of the above (plus I have no idea what compiler I used to get putch working, not gcc/Linux at least):
  • # [C (gcc)], 53 bytes
  • <!-- language-all: lang-c -->
  • *o;f(char*s){for(s=strchr(o=s,0);s-->o;)putchar(*s);}
  • [Try it online!][TIO-ktcryfme]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-ktcryfme]: https://tio.run/##FcoxDoMwDADAPa@ImGxEpO4R/UtkCImU4spOy4D4et325qOwEZmNHDNQSTIqnpkFdNYuVAR41umGUUO4c8Tnq/8X/Fq8rO7dP1Ld4c11QXc67zMMZW2NJ3@wtGXA6C77UG5pUwvHFw "C (gcc) – Try It Online"
  • # C (gcc), 62 bytes
  • main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}
  • This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.
  • ---
  • EDIT: Revisited, function-based equivalent of the above (plus I have no idea what compiler I used to get putch working, not gcc/Linux at least):
  • # [C (gcc)], 53 bytes
  • <!-- language-all: lang-c -->
  • *o;f(char*s){for(s=strchr(o=s,0);s-->o;)putchar(*s);}
  • [Try it online!][TIO-ktcryfme]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-ktcryfme]: https://tio.run/##FcoxDoMwDADAPa@ImGxEpO4R/UtkCImU4spOy4D4et325qOwEZmNHDNQSTIqnpkFdNYuVAR41umGUUO4c8Tnq/8X/Fq8rO7dP1Ld4c11QXc67zMMZW2NJ3@wtGXA6C77UG5pUwvHFw "C (gcc) – Try It Online"
#3: Post edited by user avatar Lundin‭ · 2021-09-09T10:17:44Z (over 3 years ago)
  • # C (gcc), 62 bytes
  • main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}
  • This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.
  • # C (gcc), 62 bytes
  • main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}
  • This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.
  • ---
  • Revisited, function-based equivalent of the above (plus I have no idea what compiler I used to get putch working, not gcc/Linux at least):
  • # [C (gcc)], 53 bytes
  • <!-- language-all: lang-c -->
  • *o;f(char*s){for(s=strchr(o=s,0);s-->o;)putchar(*s);}
  • [Try it online!][TIO-ktcryfme]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-ktcryfme]: https://tio.run/##FcoxDoMwDADAPa@ImGxEpO4R/UtkCImU4spOy4D4et325qOwEZmNHDNQSTIqnpkFdNYuVAR41umGUUO4c8Tnq/8X/Fq8rO7dP1Ld4c11QXc67zMMZW2NJ3@wtGXA6C77UG5pUwvHFw "C (gcc) – Try It Online"
#2: Post edited by user avatar Lundin‭ · 2020-12-01T15:57:53Z (about 4 years ago)
  • # C (gcc) 62 bytes
  • main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}
  • This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.
  • # C (gcc), 62 bytes
  • main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}
  • This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.
#1: Initial revision by user avatar Lundin‭ · 2020-12-01T15:57:25Z (about 4 years ago)
# C (gcc) 62 bytes

    main(){char b[99],*p=strchr(gets(b),0);for(;p-->b;)putch(*p);}

This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified.