I am not so clear on character pointer and how they work.
The program builds, but crashes when I run it.
char *ab = NULL; //ab = \"abc123\"; // works f
You need to allocate memory for your data. Indeed sprintf takes char*, but it doesn't allocate memory for you.
sprintf
char*
The first line works fine because compiler automatically allocates data for constant tables of chars defined at compile time.