i'm trying to input data in to an array. problem is i need to be able to access the function and enter data while the incrementer is incremented. To get rid of junk values in the indexer i've assigned it 0. Problem is the array resets itself everytime i access the function. If i dont assign a value to the indexer it shows data that makes no sense....does anyone know a way around this so that the array doesnt always automatically reset but at the same time doesnt show junk? I need to access the function via a menu but i need previous entries entered to show up without the same array area being constantly overwritten. Any help appreciated!
thanks
Code:void example (void); int main (void){ int key; printf("\n***********MENU**********"); printf("press 1 to view example"); key=getch(); if(key==1){ example(); }else printf("\nerror"); getch(); } void example (void){ int i; /*indexer*/ i=0; /*initialised*/ <---------this presents a problem as dont want it to initialise evertime i enter data as array resets. I only want it to reset if i exit the program