|
-
Dec 20th, 2001, 12:05 PM
#1
Thread Starter
Hyperactive Member
How to write a function ?
Hi,
I am new to C programming and just recently bought Deitel & Deitel's 'C: How To Program'. I just looked at the table of keywords that the C programming language has, and wondered how can there be so many c functions doing so advanced stuff with so little keywords? What is the trick behind it? Do they use lots of other tools or what? Anyway my question is: How can ppl write so many good functions which base on just the little table of keywords?
thnx in advance
-
Dec 20th, 2001, 03:37 PM
#2
Fanatic Member
Addition
Code:
void ADD(int ONE, int TWO);
void ADD(int ONE, int TWO){
return (ONE+TWO);
}

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Dec 20th, 2001, 10:16 PM
#3
Hyperactive Member
Originally posted by parksie
PS: There's no trick - if you have the source for your compiler's standard library (MSVC has it, and most others do as well) then you can read through that.
Where in MSVC? I know they include template code.
Ordinary operator code?
-
Dec 20th, 2001, 10:45 PM
#4
Frenzied Member
There's source for some ATL stuff in C:\Program Files\Microsoft Visual Studio\VC98\ATL\SRC .
By the looks of it, just about everything else is in C:\Program Files\Microsoft Visual Studio\VC98\CRT\SRC .
prog_tom: Strictly speaking, if you're going to use the usual coding conventions, you should reserve all-capitalised identifiers for constants. When you see a capitalised variable in some commercial-quality C code, it is usually a constant.
Naming conventions may sound like a pain but they're worth using. They save a lot of head-scratching when you've got a big project with other developers and you are editing code that you didn't necessarily write yourself.
Harry.
"From one thing, know ten thousand things."
-
Dec 20th, 2001, 11:29 PM
#5
Fanatic Member
Harry
Thanks for the advice Harry. Conveying you my best holiday wishes.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Dec 21st, 2001, 08:15 AM
#6
Thread Starter
Hyperactive Member
what are some other ways to check out and read the source code of the standard library, as you may know, i am only starting to learn C, not C++
-
Dec 22nd, 2001, 03:35 PM
#7
the c standard library is c, not c++.
trans: when installing vc++ you can choose to add the source of the CRT. It is then located in:
(visual studio main directory)\vc98\crt\src
Operators don't have source code. They are simply translated to asm code (e.g. + is translated to the add instruction - of course this is oversimplifying it)
iflash:
C may have few keyword, but it has a lot of operators:
+, -, =, ++, --, /, *, !, ", %, &, ^, ~, ., ->, ||, <, >, <=, >=, |, &&, ==, +=, -=, /=, %=, !=, ^=, *=, ~=, |=, &=
Some are only combinations of others, but some have several meanings.
Also, you don't need many keywords and operators. You could build a computer with less than 10 instructions (maybe a little more):
add, invert, bitshift and other bitwise operations, goto
This is basically all you need for a working computer!
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|