How to define my own header file?

I have written code for a timer. with everything and i want to include this so i dont need to write or copy the reqd code each time. how do i do this?
use the extension .h to define it as a header file
dont forget to #include it in your project
What happens if using se the guard? The functions prototype will be there. It won't generate any error but simply increase the compile time overload. Is that it?
The guard means that the functions in the header will only be defined once. Redefining a function (ie the compiler sees the prototype or the definition more than once) gives an error. With the header guard, the compiler will only see the prototypes once and then they'll be publicly accessible.
first save your code of the timer as xxx.h

then include it as #include "xxx.h" in the program after the default header files inclusion

i believe that this will go well.

I used
1
2
3
4
5
6
7
8
9
10

#include<stdlib.h>

int genrandomno(int low,int high)
{
    AB:
       t=rand()%(high+1);
       if(t<low) goto AB;
}


It is saying that i can't use int low and int high. why?

i use TURBO C++ 3.0





Where is t defined? Try to design your code to avoid the use of goto
well , i defined t and then too it says t is not allowed. yea. i am thinking about it.
Topic archived. No new replies allowed.