how to add .h file into project ?

Pages: 12
can anyone plesae tell me how to add .h file into programs ?
Last edited on
Clearly you need to go back through the tutorials on this site...

#include "filename.h"
We should just stop helping him...he isn't bothering to learn anything based on his last posts.
Create your header file and then include it.
I am learning this tutorial in a sequence . I am on Date structure right now. I will revise everything once again as return 0 said.
@ firedraco dont be rude .
Can you please tell me where in this tutorial it is mentioned how to make . h file ?
Last edited on
Can you please tell me where in this tutorial it is mentioned how to make . h file ?


I rest my case.
Last edited on
when I do #include "filename.h"
the program doesn't work.
It says no file included for filename.h.
what does it mean ?
Do you have filename.h? If so which is its path? Which is the path of your source files?
Answer these question and you will solve your problems

http://www.cplusplus.com/doc/tutorial/program_structure.html
http://www.cplusplus.com/doc/tutorial/preprocessor.html


Why did you start so many threads on headers?
http://www.cplusplus.com/forum/beginner/8083/
http://www.cplusplus.com/forum/beginner/8883/
http://www.cplusplus.com/forum/beginner/8904/
http://www.cplusplus.com/forum/general/8911/
One problem should have one thread http://www.cplusplus.com/forum/articles/1295/
Last edited on
Thanks bazzy !
I know the file name its program1.h and I made it by saving it as .h extension but How can I know the path of the file name and source files ?
Last edited on
Well, if you saved it somewhere you should know where you saved it
yes , I saved it on my desktop.
what should I do now ?
Last edited on
Weeeelll...
You need to have the "includer" in the same folder as the "included". So, say you had includeme.h on your desktop, you'd have to have iincludeyou.h on the desktop too.
There is ione folder on the desktop and everything is in it.All the files have extensions .h
I have included #include"filename.h"
as filenam.h is the actual file.
and tried to run it but it didn't work.
Last edited on
Where are your source files (*.cpp) ?
its in another folder on the desktop.
there are two folders on the desktop one is by the name of filename ( which is cpp) and the other is filename.h .
Last edited on
I said
1
2
Do you have filename.h? If so which is its path? Which is the path of your source files?
Answer these question and you will solve your problems

Anonymouse said
You need to have the "includer" in the same folder as the "included"


This is because if you are compiling the file "somepath\somefile.cpp" which includes "someheader.h" you should have "someheader.h" in the same path as "somefile.cpp" or you should specify the "someheader.h" path
Sir bazzy !
I did save both the files in the same folder.
here is what the error is .

1
2
3
4
5
6
7
8
9
10
11
12
Deleting intermediate and output files for project 'wasim', configuration 'Debug|Win32'
Compiling...
wasim.cpp
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.
Linking...
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
C:\Users\Pro Standard F.S Co\Desktop\New Folder (2)\wasim\Debug\wasim.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Users\Pro Standard F.S Co\Desktop\New Folder (2)\wasim\wasim\Debug\BuildLog.htm"
wasim - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
That is not an error with your header but with your project settings
Thank you bazzy !
I got it.
you dont have a main() function defined in any of your .cpp files and thats why this error is coming.

looks you are using VC++ 6.0??
Pages: 12