Name: Anonymous 2013-10-20 22:56
Post a random function that you made. May be from any project you've done or make one impromptu.
Any QUALITY is allowed. No bullying!
Any QUALITY is allowed. No bullying!
int con_initialize_f(FILE * ifp){
int i_width, i_height;
int c = EOF;
int i, j;
size_t m = 0;
if (fscanf(ifp, " %d x %d ", &i_width, &i_height) != 2)
return E_MALFORMED_INPUT;
if (i_width <= 0 || i_height <= 0)
return E_MALFORMED_INPUT;
g_width = i_width;
g_height = i_height;
alive_stat = calloc(g_width * g_height, sizeof(*alive_stat));
nigh_count = calloc(g_width * g_height, sizeof(*nigh_count));
freeze_alive_stat = malloc(g_width * g_height * sizeof(*alive_stat));
freeze_nigh_count = malloc(g_width * g_height * sizeof(*nigh_count));
for (j = 0; j < g_height; ++j) {
for (i = 0; i < g_width; ++i) {
do {
c = fgetc(ifp);
} while (c != ' ' && c != '.' && c != EOF);
if (c == EOF)
return E_MALFORMED_INPUT;
else if (c == '.') {
alive_stat[m] = 1;
n_add(i, j, 1);
}
m++;
}
}
return 0;
}