Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct Cuvant{
- char text[16];
- struct Cuvant *pred;
- struct Cuvant *urm;
- }Cuvant;
- Cuvant *Cuvant_nou(const char *text)
- {
- Cuvant *c=(Cuvant*)malloc(sizeof(Cuvant));
- if(!c){
- printf("memorie insuficienta");
- exit(EXIT_FAILURE);
- }
- strcpy(c->text,text);
- return c;
- }
- #define LISTAD_NUME Propozitie // numele TDA
- #define LISTAD_ELEMENT Cuvant // tipul unui element din lista
- #include "listad.h"
- Cuvant *Propozitie_cauta(Propozitie *p,const char *text)
- {
- Cuvant *c;
- for(c=p->prim;c;c=c->urm){
- if(!strcmp(c->text,text))return c;
- }
- return NULL;
- }
- int main(int argc, char* argv[])
- {
- Propozitie p;
- int op; // optiune
- char text[16];
- Cuvant *c;
- Propozitie_init(&p);
- FILE *f;
- f = fopen(argv[1], "r");
- while(fscanf(f,"[^\n]%s", text) != EOF){
- Propozitie_adauga(&p, Cuvant_nou(text));
- }
- for(c=p.prim;c;c=c->urm)printf("%s\n",c->text);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement