I'm building a program that simulates a bus going through bus stops and picking up a random amount of passengers (0-15) the problem is that when i try to print the amount of passengers that got in on a bus stop i get a lot of numbers bigger than 15.
Here's a part of my program:
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
void printList(struct Node* n)
{
while (n != NULL) {
printf(" %d ", n->data);
n = n->next;
}
}
int main()
{
struct Node*ΤΣ_ΚΤΕΛ = NULL;
struct Node*ΓΕΦΥΡΑ = NULL;
ΤΣ_ΚΤΕΛ = (struct Node*)malloc(sizeof(struct Node));
ΓΕΦΥΡΑ = (struct Node*)malloc(sizeof(struct Node));
ΤΣ_ΚΤΕΛ->data = rand()%15+1;
ΤΣ_ΚΤΕΛ->next = ΓΕΦΥΡΑ;
printList(ΓΕΦΥΡΑ);
return 0;
}