Quantcast
Channel: Tips for golfing in C - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 67

Answer by aloisdg for Tips for golfing in C

$
0
0

When you have to walk a string you can walk the pointer instead of incrementing the index.

Code :

#include <stdio.h>// print each charvoid f(char* s) {    for (int i=0;s[i];i++) putchar(s[i]);}// same output than f;void g(char* s){    for (;*s;) putchar(*s++);}int main(void) {    f("hello\n");    g("hello\n");    return 0;}

example: Remove duplicated & switched case


Viewing all articles
Browse latest Browse all 67

Trending Articles