Tis time for me to clutter up the message board with another post about things that don't work, ever...
This time I can't seem to get the code below to work properly, it'll only accept one registration, and then won't allow any further items to be input stating that the record is not empty.
Any help, suggestions, random abuse in the form of help, is always welcome..
File being opened:
if ( (v_file=fopen(FILENAME,"rb"))== NULL)
printf("\nUnable to access vehicle maintenance file");
printf("\nFile may not exist or could be corrupted");
printf("\n\aCreate new file? [Y/N]");
create = toupper(getch());
if( create != 'Y')
printf("\nUser cancelled file creation - program will end");
printf("\n\nCreating new file....");
if ( (v_file=fopen(FILENAME,"wb"))== NULL)
printf("\nUnable to create file - program will terminate");
veh->freq = 0;
printf("\nFile created succesfully");
printf("\n\n< Press any key to continue >");
The function where the error occurs:
Apologies for the length of my post
void Add_veh (FILE *v_file)
printf("\n Enter vehicle registration: ");
pos = (veh->regno - 'A') * 1000 +
(veh->regno - '0') * 100 +
(veh->regno - '0') * 10 +
(veh->regno - '0') * 1;
if(veh->freq != 0 )
printf("\n\n Record is not empty - unable to write");
printf("\n Enter vehicle make: ");
printf("\n Enter vehicle model: ");
/* Goes on and on and on, asking simple questions
to make this post shorter I'll go to the end*/
printf("\n\n\t Is the above information correct? [Y/N] ");
confirm = toupper(getch());
if(confirm == 'Y')
fseek (v_file,(pos)*STR_SIZE, SEEK_SET);
printf("\n\n Data not written to file (User intervention)\n");
But ANY help is appreciated, even if it's not about what I asked originally..
Thanks in advance...