/*------------------------------------------------------------------*/
/*| 3. set file position to the first record */
/*| 4. read the first record in the file */
/*| 5. delete it */
/*------------------------------------------------------------------*/
flocate(fileptr, &flocate_key,; sizeof(unsigned long), __KEY_FIRST);
memset(outputbuf,0x00,80);
rrds_rec->rrds_buf = outputbuf;
fread(rrds_rec,1, 88, fileptr);
printf("The first record in the file (this will be deleted):\n");
printf("RRN %d: %s\n\n",rrds_rec->rrds_key.__recnum,outputbuf);
fdelrec(fileptr);
/*------------------------------------------------------------------*/
/*| 6. locate last record in file and set access direction backwards*/
/*| 7. read the record */
/*| 8. update the record */
/*------------------------------------------------------------------*/
flocate(fileptr, &flocate_key,; sizeof(unsigned long), __KEY_LAST);
memset(outputbuf,0x00,80);
rrds_rec->rrds_buf = outputbuf;
fread(rrds_rec,1, 88, fileptr);
printf("The last record in the file (this one will be updated):\n");
printf("RRN %d: %s\n\n",rrds_rec->rrds_key.__recnum,outputbuf);
memset(outputbuf,0x00,80);
memcpy(outputbuf,"THIS IS THE UPDATED STRING... ",30);
fupdate(rrds_rec,88,fileptr);
/*------------------------------------------------------------------*/
/*| 9. set _EDC_RRDS_HIDE_KEY environment variable */
/*|10. read the next record in sequence (ie. RRN 10) into a */
/*| + character string */
/*------------------------------------------------------------------*/
setenv("_EDC_RRDS_HIDE_KEY","Y",1);
memset(outputbuf,0x00,80);
fread(outputbuf, 1, 80, fileptr);
printf("The middle record in the file (read into char string):\n");
printf("%80s\n\n",outputbuf);
fclose(fileptr);
}
|