Hi All,

I am new to c programming.
I have mulptiple c files which uses the client.h
Currently I am using my header file in each and every place where my c code is placed.
Can I put it at one particular location and use it as #include<client.h> in my all c code?

Please help me where I should put my header file in case of Linux as my operating system.

Thanks

Yes ... you can have a file to be included ... that is just a list of other file 'includes' ... that you need included. Make sure that you have 'unique guards' in the .h header files...

Note: you can NOT define the same thing after it has been previously define ... not allowed in C/C++ (like it is in Python ... where a name can be reused and bound to anything ... on the fly.)

#ifndef HEADER_FILE1_H
#define HEADER_FILE1_H

// ... ALL your declarations go here ...

#endif

These guards are to prevent the same header files ... (used/needed by various .cpp files, to be complied) ... to be included more than once.

Some compilers complain if the include files you create are in quote or angle bracks

#include "client.h"

Use quotes if client.h is in the same folder as your *.c file(s)

#include <client.h>

Use angle brackets if client.h is in the compiler's include folder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.