Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Candidato *consultarand(char *nome, Hash tab, long long int inscr)
  2. {
  3. Candidato *aux, *c;
  4. int endreg;
  5. size = sizeof(Candidato);
  6. int h = hashf(inscr);
  7. for (aux = tab[h] ; aux != NULL ; aux = aux->prox){ //percorre tabela hash para saber se a inscrição existe
  8. if (tab[h] == NULL){
  9. printf ("\nRegistro inexistente \n");
  10. return NULL;
  11. }
  12. if (aux.inscr == inscr){
  13. break; //inscrição existe na tabela
  14. }else{
  15. return NULL;
  16. }
  17. }
  18.  
  19. FILE *arq = fopen (*nome, "rb");
  20. endreg = (h - 1) * size; //calcula o endereço do registro
  21. fseek (arq, size, endreg); //desloca o cursos para o endereço calculado
  22. fread (&c, size, 1, arq); //le a estrutura candidato presente naquele endereço
  23. return c;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement