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

Answer by klingt.net for Tips for golfing in C

$
0
0

Using asprintf() saves you the explicit allocating and also measuring the length of a string aka char*! This isn't maybe too useful for code golfing, but eases the everyday work with a char arrays. There are some more good advises in 21st Century C.

Usage example:

#define _GNU_SOURCE#include <stdio.h>int main(int argc, char** argv) {  char* foo;  asprintf(&foo, "%s", argv[1]);  printf("%s",foo);}

Viewing all articles
Browse latest Browse all 67

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>