< Pemrograman C < pustaka
assert.h adalah file header di perpustakaan standar bahasa pemrograman C yang mendefinisikan makro preprocessor C assert(). Dalam C ++ ini juga tersedia melalui file header <cassert>.
Contoh
#include <stdio.h>
#include <assert.h>
int test_assert(int x)
{
assert(x <= 4);
return x;
}
int main()
{
int i;
for (i=0; i<=9; i++)
{
test_assert(i);
printf("i = %d\n", i);
}
return 0;
}
i = 0 i = 1 i = 2 i = 3 i = 4 assert: assert.c:6: test_assert: Assertion `x <= 4' failed. Aborted
Selengkapnya
- Mengenai Assert.h (dalam bahasa Inggris)
| ||||||||||||||
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.