Results 1 to 5 of 5
Hello,
In the last few days I've learnt how to edit ,compile and build some simple programs using C/C++ languages.
But there are some issues that still confuse me:
1- ...
- 06-29-2009 #1Just Joined!
- Join Date
- Jun 2009
- Posts
- 16
Beginner programming questions.....
Hello,
In the last few days I've learnt how to edit ,compile and build some simple programs using C/C++ languages.
But there are some issues that still confuse me:
1- Why is the source of a large program divided into several pieces of (.c)and (.h) files? and how do I divide a program with functions and classes and library headers into .c and .h files?
.c --> C code
.h --> header file (like function defenitions and #using<library.h> and DEFINE ????)
2-Some programs have some script fiiles and perl files beside the .c/.cpp files........Why do they mix several program languages? I've heared that script files sometimes can fix problems with installing the software ...is that the only purpose? and what's the purpose of the .pl perl files???
An example of such a program with several .c , .h , .sh , .pl files ---> is snort .......
3- My third question is about the configure file....How does it work?How does it create the makefile??
The reason why I'm asking is that I need to fully understand the programming of snort in order to modify it to be more suitable to my NETWORK....... Which is my graduation project....
Thanks in advance....
- 06-29-2009 #2
You might get more responses if you didn't post a shopping list of questions....One post, one or two questions...G4143
Make mine Arch Linux
- 06-29-2009 #3
For the sake of clarity, efficency and to avoid redundancy.
a) Several small files are easier maintained than one single big one.
b) "Translation units" can be compiled separately and linked together later.
So if you change one line in one file, not the complete project has to be compiled anew. This saves time.
c) Header files can be shared between several .c files. So the information in them needs only to be written once, and every other file knows about this.
If this doesn't make too much sense for you, search in your learning book for "declaration versus definition".
Every programming language has its strengths and weaknesses. Choosing the right tool for a given a job is half the success. Script files are mostly convenience programs that spare you to write many commands repeatedly.
It scans your computer for where all the programs it needs reside and if all necessary dependencies (other programs) are installed. These tasks need only to be done once for a given system (and project) because this information does usually not change when you modify the program.Debian GNU/Linux -- You know you want it.
- 06-29-2009 #4
For size and organizational purposes. Sure, it may seem like overkill for a small program that's less than 100 lines to split it up between headers and source files, but when you get into multi-file programs that are several thousand (or hundreds of thousands) of lines long it gets to be a logistical nightmare to remember where and how you defined this structure or procedure.
In the case of Linux programs, a lot of the time the main program is written in C, but the install script is easier to do with a scripting language like Perl or Python.2-Some programs have some script fiiles and perl files beside the .c/.cpp files........Why do they mix several program languages? I've heared that script files sometimes can fix problems with installing the software ...is that the only purpose? and what's the purpose of the .pl perl files???Registered Linux user #270181
TechieMoe's Tech Rants
- 07-01-2009 #5Just Joined!
- Join Date
- Jun 2009
- Posts
- 16
@gerard:
Actually Ive got some pretty excellent responses from GNU-Fan and techieMoe so far......
Forgive me if I'm asking some beginner questions, but I think that posting a shopping list of questions is better than a shopping list of topics (as long as all questions are related)......


Reply With Quote
