Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int save_dictionary_b(const struct dictionary_t *d, const char *filename)
- {
- if(!d || !filename || !d->wc || d->capacity<=0 || d->size<0 || d->size>d->capacity)
- return 1;
- FILE *f=fopen(filename, "wb");
- if(!f)
- return 2;
- fwrite(&(d->size), sizeof(int), 1, f);
- int size=d->size;
- for(int i=0; i<size; i++)
- {
- int len=strlen((d->wc+i)->word);
- fwrite(&len, sizeof(int), 1, f);
- fwrite(&((d->wc+i)->word), sizeof(char), len, f);
- fwrite(&((d->wc+i)->counter), sizeof(int), 1, f);
- }
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement