Rules | Recent posts | topic RSS | Search | Register  | Log in

Header files in c++

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Author Message
wansaidatulakma



Joined: 27 Jul 2006
Posts: 3


Post06 Aug 2008 5:49   Header files in c++

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.....
Back to top
m_pourfathi



Joined: 07 Feb 2008
Posts: 204
Helped: 13


Post06 Aug 2008 6:12   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
Back to top
VirtualThread



Joined: 04 Aug 2005
Posts: 84
Helped: 4


Post06 Aug 2008 7:13   Re: Header files in c++

wansaidatulakma wrote:
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?
Back to top
randell_xtian



Joined: 25 Mar 2008
Posts: 150
Helped: 8
Location: Philippines


Post06 Aug 2008 11:46   Re: Header files in c++

Hi,

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

best regards,
randell_xtian Very HappyVery HappyVery HappyVery Happy
Back to top
mezo



Joined: 16 Jul 2007
Posts: 60
Helped: 2
Location: Egypt


Post17 Aug 2008 15:04   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
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap