int* function() {
static int value;
return &value;
}
int* function() {
return calloc(0, sizeof(int));
}
struct multi_purpose_data {
char *string;
double value;
};
typedef struct multi_purpose_data MP_DATA;
static bool isInit = FALSE;
MP_DATA find_path(int in_room_vnum, int out_room_vnum, CHAR_DATA *ch, int depth, bool_t in_zone, bool_t isPath) {
static MP_DATA mp_data;
mp_data.value = -1;
if (isINIT)
free_string(&mp_data.string);
isInit = TRUE;
if (***)
mp_data.string = '\0';
else
mp_data.string = strdup(something);
***
return mp_data;
}
char* function() {
static char buffer[256];
strcpy(buffer, "meh");
return &buffer[0];
}
Is the only way to know you already entered the method once is to use a static boolean ? how do you initialize a local static data ?
I did not find a good C course about those.