#include <stdio.h>
#include <stdlib.h>
#include <time.h>

struct item {
    char text[64];
    struct item *next;
};

int main(void) {
    int i=0, /* i : Number of Items          */
        c=0, /* c : Position in the list     */
        r=0; /* r : Random number            */
    struct item *list=NULL, /* list : begin  */
                *p=NULL; /* p : current item */

    srand(time(NULL));
    printf("Number of Items: ");
    do { scanf("%d", &i); } while (getchar() != '\n');

    if (i <1) {
        printf("Proposed Item: Suicide\n");
        return EXIT_SUCCESS;
    }

    if((list = malloc(sizeof(struct item))) != NULL) {
        p = list;
        printf("Enter Item #%02d: ", c+1);
        fgets(list->text, 64, stdin);
    }

    for(c=1; c<i; c++) {
        if ((p->next = malloc(sizeof(struct item))) != NULL) {
            p = p->next;
            p->next = NULL;
            printf("Enter Item #%02d: ", c+1);
            fgets(p->text, 64, stdin);
        }
    }
    r = rand()%i;
    p=list;
    for (c=0; c<r; c++) {
        p=p->next;
    }
    printf("Proposed Item(#%02d): %s", r+1, p->text);
    return EXIT_SUCCESS;
}
