I have the following program. Everything seems ok, the only problem is that the wight always prints 0.
How can i fix that
Code:
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
void printCat(CAT);
//void compare (CAT, cat27, max);
typedef struct {
double weight;
char name[50];
int neutered;
}CAT;
int main(){
int size=0;
int index=0;
int i;
CAT* heardOfCats;
char*name[6]={"Fluffy", "Tigger", "Max", "Betty", "Cat27","Jake"};
CAT max;
srand(time(NULL));
printf("Please enter the number of cats: ");
scanf("%i", &size);
heardOfCats=calloc(size, sizeof(CAT));
strcpy(max.name,"Max");
max.weight=12;
max.neutered=TRUE;
printCat(max);
for(i=0; i<size; i++){
index = rand() % 6;
strcpy(heardOfCats[i].name, name[index]);
heardOfCats[i].neutered=rand()%2;
printf("%s ",heardOfCats[i].name);
printf(" %i ", heardOfCats[i].weight);
printf("%i ",heardOfCats[i].neutered);
printf("\n");
}
system("Pause");}
void printCat(CAT max){
printf("%s\n", max.name);
printf("%.1lf\n", max.weight);
printf("%i\n", max.neutered);}