Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // lab 4 FIN
- //
- // Created by Aleksandra Kustra on 27.03.2017.
- // Copyright © 2017 Aleksandra Kustra. All rights reserved.
- //
- #include <stdio.h>
- #include <stdlib.h>
- struct napis {
- char *str;
- unsigned int len;
- int iloscWstapien;
- };
- /////////////////////
- void ileRazyWystapily(struct napis *tab) {
- int i, j;
- for(i = 0; i < sizeof(tab); i++) {
- for(j = 0; j <=i; j++) {
- if(tab[i] == tab[j]) tab[i].iloscWstapien ++;
- }
- }
- }
- /////////////////////////
- int main() {
- int wielkosc, i = 0, j;
- struct napis *tab;
- FILE *napisy = fopen("napis.txt", "r");
- rewind(napisy);
- //pobiera 1 linijke - ilosc napisow
- fscanf(napisy, "%d", &wielkosc);
- printf("%d\n", wielkosc);
- tab = malloc(wielkosc*sizeof(struct napis));
- if(napisy) {
- while(fscanf(napisy, "%d", &tab[i].len) != EOF) {
- tab[i].str = malloc((tab[i].len+1)*sizeof(char));
- fscanf(napisy, " %s", tab[i].str);
- i++;
- }
- }
- free(tab);
- free(tab[i].str);
- fclose(napisy);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement