I think it can be simplified quite a bit from the link you give.
Either way, you'll need a queue.
Can you implement a queue that passes the following test?
Code:
int main(void) {
Queue q; // int front, back; Pos pos[QUEUE_SIZE]
qInit(&q); // set front and back to 0
Pos a = {1, 2}; // Pos has row, col (in that order)
qPush(&q, &a);
Pos b = {5, 3};
qPush(&q, &b);
while (!qEmpty(&q)) {
Pos p;
qPop(&q, &p);
printf("%d, %d\n", p->row, p->col);
}
//qTerm(&q); // if needed (dynamic allocation)
return 0;
}