#include<assert.h>
#include<stdio.h>
**#include<stdlib.h>**
#include<string.h>
**#include<stdlib.h>**
#include<time.h>
stdlib.h is included for two times, but why?
#include<assert.h>
#include<stdio.h>
**#include<stdlib.h>**
#include<string.h>
**#include<stdlib.h>**
#include<time.h>
stdlib.h is included for two times, but why?
There is exactly one non-idempotent standard header in the C standard: <assert.h>
.
C++ inherits that and adds its own adaptation: <cassert>
.
Even for those, multiple inclusion has no effect without changing NDEBUG
between them.
Your own headers, as well as headers from other libraries you might use, should use include guards (or the unportable but often working #pragma once
).
If you sort your headers (include the implementation-files own header first though), you can easily eliminate duplicates and don't need to rely on that.