Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C by registered user raphael ( 2 years ago )
#include <stdio.h>
#include <limits.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdarg.h>
//auteur : Raphael De Oliveira
static struct livre* premier;
static struct livre* fin;
struct livre{
char* titre;
char* auteur;
short int age;
struct livre * suivant;
}__attribute__((packed));
void increment_element(struct livre* elem){
*elem=*elem->suivant;
}
void ajout(char * t, char* a, int y){
struct livre* s;
s = malloc(sizeof(struct livre));
s->titre = t;
s->auteur = a;
s->age = y;
s->suivant = NULL;
if(premier==NULL){
premier=s;
fin = premier;
return;
}
fin->suivant = s;
fin = s;
}
void main(int argc, char *argv[]){
//struct livre l1 = {"Le bruit et la fureur", "William Faulkner", 1, NULL};
//struct livre l2 = {"Demande à la poussière", "John Fante", 1, NULL};
//struct livre l3 = {"À la recherche du temps perdu", "Albert Camus", 1, NULL};
//struct livre l4 = {"Madame Bovary", "Gustave Flaubert", 1, NULL};
//struct livre l5 = {"La Divine Comédie", "Léon Tolstoï", 1, NULL};
premier = NULL;
ajout("À la recherche du temps perdu","Albert Camus",10);
ajout("Demande à la poussière", "John Fante", 12);
ajout("À la recherche du temps perdu", "Albert Camus", 2);
ajout("Madame Bovary", "Gustave Flaubert", 200);
ajout("La Divine Comédie","Léon Tolstoï",30);
struct livre* elem = malloc(sizeof(struct livre));
elem = premier;
printf("Voici la liste chainée trié par ordre alphabétique par noms d'auteurs des livres de la bibliotheque :\n\n");
while(elem->suivant!=NULL){
printf("%s | %s\n",elem->titre,elem->auteur);
//elem=elem->suivant;
increment_element(elem);
}
printf("%s| %s\n",elem->titre,elem->auteur);
return;
}
Revise this Paste