Código
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define MAX_BUCKETS 512 /* the index size and the maximum number of buckets */ #define SIZE 10 /* the number of records per bucket */ struct rec_tag { char key_field[21]; /* other data fields as necessary */ }; typedef struct buck_tag { long number_of_records; int bucket_bits; struct rec_tag record[SIZE]; } BUCKET; struct head_tag { int bits_used_in_index; long buckets_used; }; int main() { int depth, bits; int i , limit; int sub; int record_found; long rrn; long address; int begin_new, end_new; long bucket_address; long bucket_table[MAX_BUCKETS]; /* this will hold actual byte offsets rather than rrn */ long index_size; long positions_used; BUCKET bucket; BUCKET new_bucket; struct rec_tag record; struct head_tag header_record; FILE *buckets; FILE *index; /* at this point would be a call to a function that would fill the structure called record with valid data */ sub = makesub(record.key_field, header_record.bits_used_in_index); for(i=0, record_found=1; i < bucket.number_of_records && record_found != 0; i++) if(record_found == 0) { } else { if(bucket.number_of_records < SIZE) { bucket.number_of_records += 1; } else /* the bucket is full and must be split */ { if(bucket.bucket_bits == header_record.bits_used_in_index) header_record.bits_used_in_index = doublidx(header_record.bits_used_in_index, bucket_table); moverecs(&bucket, &new_bucket); header_record.buckets_used += 1; /* now comes the tricky bit. the address of the new bucket must be inserted into the appropriate place(s) in the index. first, get the subscript for the table entry from any key in the new bucket. */ sub = makesub(new_bucket.record[0].key_field, header_record.bits_used_in_index); rrn = bucket_table[sub]; for(i=0; i < limit; i++) { if(bucket_table[i]==rrn) break; } begin_new = i; for(;bucket_table[i]==rrn && i < limit; i++) end_new = i; begin_new = begin_new + (end_new - begin_new + 1) / 2; for(i=begin_new; i <= end_new; i++) bucket_table[i] = bucket_address; /* now that the index and bucket maintenance is done, the rest is simple retrieve the bucket and add the new record. */ sub = makesub(record.key_field, header_record.bits_used_in_index); bucket.number_of_records += 1; } /* end else */ } /* end else */ return 0; }
me salen los siguientes errores kuando ingreso el código cc nombre.c -lm -o nombre.exe -lrt
c.c:(.text+0xe4): referencia a `makesub' sin definir
c.c:(.text+0x28a): referencia a `doublidx' sin definir
c.c:(.text+0x2a5): referencia a `moverecs' sin definir
c.c:(.text+0x364): referencia a `makesub' sin definir
c.c:(.text+0x513): referencia a `makesub' sin definir
collect2: error: ld returned 1 exit status