C: Exemple d’utilisation des assertions

Author:

 assert
{filelink=13883}


#include 
#undef NDEBUG
#include 

void main()
{
  int x = 0;
  int y = 5;
  for(x = 0 ; x < 20 ; x++)
  {
    printf("x = %d   y = %d", x, y);
    assert(x<y);// Erreur dans le cas contraire
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *