Thanks for your reply subsonics ive made the changes you suggested but im getting an error message now ((warning return type of 'main' is not int)) so i thought id post all the code. This was a sample menu program given to us by our teacher, i have only edited void_book() so far all the rest is mostly untouched.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* global variables */
typedef struct
{
char ISBN[20];
char Author[50];
char Title[50];
}record_structure;
FILE *record_file;
int choice;
record_structure record_array[8];
int num_records;
/* function prototypes */
void intro();
void menu();
void close();
void add_book();
void option2();
void option3();
void option4();
void screen_pause();
/*******************************************************************************************/
void main()
{
intro();
do
{
menu();
}
while (choice!=5);
close();
}/* end of main function */
/*******************************************************************************************/
void intro()
{
system("cls");
printf("\n\n\n\n\n\n\tWelcome to Forth Valley's Collection of Technical Books");
screen_pause();
}/*end of intro function*/
/*******************************************************************************************/
void add_book()
{
record_file = fopen("C:\\bookfile.bin","wb");
system("cls");
printf( "\n\nAdd book details");
for(num_records=0;num_records<=7;num_records++)
{
printf( "\n\nISBN: ");
fflush(stdin);
fgets(record_array[num_records].ISBN, size, stdin);
printf( "\n\nAuthor: ");
fflush(stdin);
fgets(record_array[num_records].Author, size, stdin);
printf( "\n\nTitle: ");
fflush(stdin);
fgets(record_array[num_records].Title, size, stdin);
printf( "------------------------------------" );
fwrite(&record_array[num_records],sizeof(record_structure),1,record_file);
}
fclose(record_file);
screen_pause();
}/* end of dummy menu option 1 function */
/*******************************************************************************************/
void option2()
{
system("cls");
printf("Search for ISBN ");
screen_pause();
}/* end of dummy menu option 2 function */
/*******************************************************************************************/
void option3()
{
system("cls");
printf("Search for a book by title ");
screen_pause();
}/* end of dummy menu option 3 function */
/*******************************************************************************************/
void option4()
{
system("cls");
printf("Show details of all books ");
screen_pause();
}/* end of dummy menu option 4 function */
/*******************************************************************************************/
void close()
{
system("cls");
printf("\n\n\n\n\n\n\tThank you for using this program");
screen_pause();
}/* end of close function */
/*******************************************************************************************/
void menu()
{
system("cls");
printf("\n\nMENU");
printf("\n\n1 - Add new entry: ");
printf("\n2 - Book search by ISBN: ");
printf("\n3 - Book search by title: ");
printf("\n4 - Show details off all books stored: ");
printf("\n5 - Exit Program:");
printf("\n\nEnter your choice ");
scanf("%i", &choice);
while((choice<1)||(choice>5))
{
printf("\n\nYou eneterd an invalid number please enter a valid number");
printf("\n\n\tEnter your choice: ");
scanf("%i", &choice);
}
switch(choice)
{
case 1 : add_book();break;
case 2 : option2(); break;
case 3 : option3(); break;
case 4 : option4() ; break;
case 5 : break;
}
}/* end of menu function */
/*******************************************************************************************/
void screen_pause()
{
printf("\n\n\tPress any key to continue.....");
getch();
}/* end of screen_pause function */