Your problem is that within the loop, you write *option_string++. This means that once the loop is done, you're going to be pointing past the end of the string:
option_string at start
|
V
+----+----+----+----+----+
| | | | | |
| | | | | |
+----+----+----+----+----+
^
|
option_string at end
Note that this reveals a second problem with your code: strings in C are null-terminated, but this string will eventually contain "aaaaa" and then… who knows? Garbage, most likely, but you can't tell. You need a six-length string. Fixing the first problem means using simple indexing instead: option_string[j] = 'a'. If you really want the *option_string++ method, you'll have to save and restore option_string (char * real_option_string = option_string; ... option_string = real_option_string;), but I wouldn't recommend it. Fixing both of these bugs, and a couple of style things, gives you:
#include <stdlib.h>
#include <stdio.h>
int main (void)
{
char * option_string = calloc(6, sizeof(char));
int j;
for ( j = 0; j < 5; j++)
{
option_string[j] = 'a';
}
printf("print options_string: %s\n", option_string);
free(option_string);
return 0;
}
The other thing I changed was your malloc usage. I feel like calloc is a better stylistic choice here; calloc(count, size) allocates count objects of size size, and zeros them. It's like malloc(count*size) plus a memset, but feels cleaner to me. You also shouldn't have a cast on malloc/calloc/etc., generally speaking (it can obscure useful warnings), and you need to allocate six slots, like I said (so you can have the null-terminator, which is the zero-valued character, so we don't need to set it explicitly). Combine that with the option_string[j] indexing mode, include the missing stdlib.h for calloc (you should have had it for malloc, too), and we're good to go!