I wouldn't do it that way. Sounds too Rube Goldberg.
If you have more data to organize, I'd suggest using a struct, and putting everything connected with one item, inside the struct:
Code:
struct mystruct: //define the struct
int myInt;
time_t myTimeStamp; //don't know if time_t is right for you, however
char myString[25];
//etc.
} oneStruct; //make one instance of mystruct
Then make an array of your struct. You can think of each struct, as an object.
Fall through on a switch statement:
It's sing along time!
On the 12th day of Christmas, my true love gave to me:
Code:
/* switch.c
Switch Statement Fall Through Example
*/
#include <stdio.h>
int main(void) {
int day;
printf("\n\n\tWhich day of Christmas do you want to see presents for? ");
scanf("%d", &day);
putchar('\n');
switch(day) {
case 12: printf("\t12 drummers drumming\n");
case 11: printf("\t11 pipers piping\n");
case 10: printf("\t10 Lord a'leaping\n");
case 9 : printf("\t9 ladies dancing\n");
case 8: printf("\t8 maids a'milking\n");
case 7: printf("\t7 swans a'swimming\n");
case 6: printf("\t6 geese a'laying\n");
case 5: printf("\tFive Golden Rings\n");
case 4: printf("\t4 calling birds\n");
case 3: printf("\t3 french hens\n");
case 2: printf("\t2 turtle doves, and\n");
case 1: printf("\ta partridge, in a pear tree\n");
};
printf("\n\n\t\t\t Press Enter When Ready ");
day = getchar(); day = getchar();
return 0;
}
By stacking up the gifts in descending order of days, and using the switch statements "fall through" feature, the repetitive (or multi-function), code that would be needed, is neatly eliminated.