I want to create a header file for C, C++ which is specific to help in randomization.
views:
333answers:
3I'm still not sure that I understand your question (I posted a comment to your question), but an answer might be this:
#include <stdlib.h> /* required for rand() and srand() */
This is the answer if you want to invoke the rand() and srand() functions, which are part of the C standard library. For example, see http://www.google.com/search?q=srand
Try looking at http://www.daniweb.com/forums/thread1769.html, kasperasky, and see if it helps you to answer your question--or at least ask a little more specific question.
Header files are C files, except that they shouldn't contain any code implementation (only declarations).
For example, suppose the C file "dummy.c":
int dummy_function(int x){
return x+1;
}
A good C header file would be:
#ifndef _DUMMY_HEADER_H_
#define _DUMMY_HEADER_H_ //This helps solve some possible errors
int dummy_function(int x);
#endif
If you use structures as arguments (or return values), you should put their declaration in the header.
typedef struct { int value; } myStruct;
int dummy_function(myStruct* x){
return (*x).value+1;
}
Instead, you should write
#include "dummy.h"
int dummy_function(myStruct* x){
return (*x).value+1;
}
And create the following header file:
#ifndef _DUMMY_HEADER_H_
#define _DUMMY_HEADER_H_
typedef struct{ int value; } myStruct;
int dummy_function(myStruct* x);
#endif
A good header file should be valid by itself (include all the '#include' statements it needs).
So, if your code is the implementation of a "double myRandom()" function, you should write this header file:
#ifndef _HEADER_NAME_
#define _HEADER_NAME_
double myRandom(void); /* Can omit void in C++, but not in C */
#endif
If this isn't your problem, then please specify better.