Results 1 to 7 of 7

Thread: How to write a function ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    484

    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

  2. #2
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post 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

  3. #3
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    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?
    I'm a VB6 beginner.

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  5. #5
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post 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

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    484
    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++

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width