Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<conio.h>
- #define N 10000
- typedef struct Lista
- {
- char data[N];
- struct Lista *next;
- }Filmes;
- typedef struct ListaDupla
- {
- char pessoa[N];
- struct ListaDupla *prox;
- struct ListaDupla *ant;
- }DuplaLista;
- struct Lista* Insert(struct Lista *head,char data[N])
- {
- char aux3[N];
- struct Lista* tmp=((struct Lista*)malloc(sizeof(struct Lista)));
- int aux5;
- strcpy(tmp->data,data);
- tmp->next=NULL;
- if(head==NULL)
- {
- head=tmp;
- return head;
- }else
- {
- struct Lista* aux=head;
- struct Lista* aux2=head;
- while(aux->next!=NULL){
- aux=aux->next;
- }
- aux->next=tmp;
- while(aux!=NULL)
- {
- aux2=aux2->next;
- while(aux2!=NULL)
- {
- aux5=strcmp(aux->data,aux2->data);
- if(aux5>0)
- {
- strcpy(aux3,aux->data);
- strcpy(aux->data,aux2->data);
- strcpy(aux2->data,aux3);
- }
- }
- aux=aux->next;
- }
- return head;
- }
- // Complete this method
- }
- int main()
- {
- struct Lista* filmes=((struct Lista*)malloc(sizeof(struct Lista)));
- int opcao;
- char aux2[N];
- FILE *arq;
- arq=fopen("nomes.txt","rt");
- int i,a=0,b,aux;
- char linha[600],nome[100];
- if(arq==NULL)
- {
- printf("Ocorreu um erro!");
- return 1;
- }
- while(fgets(linha,700,arq))
- {
- char *p=strtok(linha,",");
- filmes=Insert(filmes,p);
- while(filmes->next!=NULL)
- {
- printf(" n Nome:%s",filmes->data);
- filmes=filmes->next;
- }
- }
- fclose(arq);
- }
Add Comment
Please, Sign In to add comment