regarding unix specific commands

Discussion in 'C Programming' started by fidlee, Jan 1, 2006.

  1. fidlee

    fidlee Guest

    I dont know if this is the right place to ask this question.

    i got this book "The C Odyssey. Unix - The Open, Boundless C"
    It is a 1992 edition book

    The book speaks of all the unix specific functions

    Just quoting an example below:

    void main()
    {

    int pid;
    pid=getpid();
    printf("Process id is \n",pid);

    }

    I would like to know if this should run on any linux flavour(since this
    book talks only on unix/) with gcc compiler installed on it.What I
    would like to know is if this book would prove useful to me if i would
    like to play around with Linux.

    Thanks in advance
     
    fidlee, Jan 1, 2006
    #1
    1. Advertisements

  2. fidlee said:
    That's a bad sign. In C, main returns int, not void. There were a couple of
    other problems with the code, too.

    My own personal recommendations for Linux programming are "The Unix
    Programming Environment" (Kernighan and Pike), "Linux Programming by
    Example" by Kurt Wall, and "Advanced Programming in the Unix Environment"
    (W Richard Stevens).

    Probably in that order. And of course any other book by WRS, too.

    But this newsgroup is about C, not about Unix or Linux, so I suggest you
    seek further inspiration in comp.unix.programmer or
    comp.os.linux.development.apps or something of that ilk, where you will get
    much better answers to your Linux questions than you could possibly hope
    for in this group.
     
    Richard Heathfield, Jan 1, 2006
    #2
    1. Advertisements

  3. ^^^^
    You're dead already.
    If this book really has main with a void return type, burn the book.
    Quickly.
     
    Martin Ambuhl, Jan 1, 2006
    #3
  4. Martin Ambuhl said:
    Unless it's an intentional example of How Not To Write C. I am uncomfortably
    aware that it is possible for advice along the lines of "DON'T DO THIS!" to
    be read by some people as if it comprised not three words, but two. (I am
    thinking particularly of the fflush(stdin) example in "C Unleashed".)
     
    Richard Heathfield, Jan 1, 2006
    #4
  5. fidlee

    Chuck F. Guest

    I wonder if that could be an example of BullSchildt?

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
     
    Chuck F., Jan 1, 2006
    #5
  6. Burn it.

    DES
     
    =?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=, Jan 1, 2006
    #6
  7. fidlee

    eerok Guest

    On 31 Dec 2005 21:51:38 -0800, fidlee wrote:

    [getpid()]
    Do "man getpid" and you'll see that it conforms to posix, so
    it should be widely available on linux systems. You can do
    the same kind of check for any of the other functions you want
    to use from that book. Reading the man page for functions
    you're curious about is common sense on unix in any case.

    This isn't topical here, but it's offered in the spirit of
    "teach a man to fish ..."
     
    eerok, Jan 1, 2006
    #7
  8. fidlee

    Malcolm Guest

    In English academic writing we use a star to represent illegal forms

    e.g.

    *English as she is spoke.

    You need some silimar convention for C examples.
     
    Malcolm, Jan 1, 2006
    #8
  9. fidlee

    Pradyut Guest

    --
    Pradyut
    http://pradyut.tk
    http://groups.yahoo.com/group/d_dom/
    http://groups-beta.google.com/group/oop_programming
    India
    You missed %d in the line
    printf("Process id is %d\n",pid);

    And int main not void, with a return before ending the program

    Whatever, if the book talks about gcc, gcc package remains the same,
    whatever flavour u may be using for unix(or linux).
    Ofcourse the path for the libraries and hardware interrupts may change
     
    Pradyut, Jan 2, 2006
    #9
  10. fidlee

    Chuck F. Guest

    Pradyut wrote:

    Absolutely nothing, except a 66 line signature, which is
    automatically discarded on reply by the better newsreaders.

    In other words, a sig-line belongs at the end, after your comments,
    which in turn may be either interspersed or after the *clipped*
    material you quote.

    Some newsreaders have (mistakenly) allowed a sig to be injected at
    the head of quoted material. This option should *never* be used.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
     
    Chuck F., Jan 3, 2006
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.