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);}