Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/ecole_etude_fac_de_pau/licence_3/systeme-d-exploitation/tp1/adresse.c~

(Deskargatu)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "adresse.h"


#ifndef adressedef
#define adressedef 1



Adresse* CreerAdresse(int a,char* b,int c, char* d)
{
  Adresse* pr=NULL;
  if ((pr = (Adresse*)malloc(sizeof(Adresse))) == NULL)
    {
      perror("Malloc erroc");  exit(-1); 
    }
  pr->iNum = a;
  char* temp;
  temp = (char*)malloc(sizeof(char)*strlen(b)+1);
  strcpy(temp,b);
  pr->sRue= temp;
  pr->iCodePostal = c;
  temp = (char*)malloc(sizeof(char)*strlen(d)+1);
  strcpy(temp,d); 
  pr->sVille = temp;

  return pr;
}


void AfficheAdresse(Adresse* a)
{
  printf("Adresse:\n\tNumero: %d\n\tRue:%s\n\tCP:%i\n\tVille:%s\n",
	 a->iNum,a->sRue,a->iCodePostal, a->sVille);
}

void SupprimeAdresse(Adresse* a)
{
  free(a->sRue);
  free(a->sVille);
   free(a);

}


#endif