Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

What is the function for header files in C++ and how to use it

Status
Not open for further replies.

wansaidatulakma

Newbie level 3
Joined
Jul 27, 2006
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
i am a c++ beginner. i want to know what is the function of header file in c++ and how to use it..plzz help me.....
 

m_pourfathi

Full Member level 4
Joined
Feb 7, 2008
Messages
201
Helped
17
Reputation
34
Reaction score
3
Trophy points
1,298
Activity points
2,592
Re: Header files in c++

Header Files are like libraries having functions and other primary definitions in your program. For instance you are creating a program which gives you the output in the command prompt.
you have to use the such syntax:

cout << "Your output"

cout is defined in the header file iostream.h which can be load by using #include <iostream.h>. In other words, using such syntax, is like adding all the lines in iostream file to your program.

Syntaxes followed after # are called preprocessing syntaxes. They are executed before the execution of your main program.

you also can visit www.cplusplus.com
or you can use the book "How to program C++" authored by deitel and deitel.

Regards,

m_pourfathi
 

VirtualThread

Member level 5
Joined
Aug 4, 2005
Messages
80
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,288
Location
US
Activity points
1,806
Re: Header files in c++

wansaidatulakma said:
i am a c++ beginner. i want to know what is the function of header file in c++ and how to use it..plzz help me.....
Are you new to programming as well?
OR
Have you programmed in any other language like Java?
 

randell_xtian

Full Member level 4
Joined
Mar 25, 2008
Messages
203
Helped
28
Reputation
56
Reaction score
15
Trophy points
1,298
Location
Philippines
Activity points
2,667
Re: Header files in c++

Hi,

header files are files or a library for specific purposes...

best regards,
randell_xtian :D:D:D:D
 

mezo

Member level 5
Joined
Jul 16, 2007
Messages
81
Helped
12
Reputation
24
Reaction score
8
Trophy points
1,288
Location
Egypt
Activity points
1,738
Re: Header files in c++


Header files are libraries which include prototypes of all functions used in C language
prototype is a line that you write at the beginning of any C program , it is like the
function deceleration except you add semi colon (; ) after it .

for example :
int line (void); // this is a prototype for a function named line .

the previous line must be written before the main function , or you will have an error message tells you : function line must have a prototype .

when do i have to write the prototype ?

a prototype in the head of a program is to tell the compiler that there is a function
in the code to be invoked . so it would be considered .
does this mean that any function you use have a prototype ? that is correct .

even functions like : printf , cout , scanf , getche, ...etc have prototypes .
these prototypes are in the header files so if you noticed you don't write them
again. so you have to include the header file you need in the program to be
compiled . i'll give you an example : printf function's prototype is in the header file
(stdio.h) so you have to include it in the program if you want to use printf function
cout prototypes is in (iostream.h) etc .

hope be usefull
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top