completely stuck

Discussion in 'C Programming' started by Bill Cunningham, May 29, 2008.

  1. I have this code and it will not compile telling me that pow is
    undefined. I'm not quite sure what to make of this so I thought I'd get some
    feedback.

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>

    int
    main (int argc, char *argv[])
    {
    if (argc != 3)
    {
    puts ("usage error");
    exit (EXIT_FAILURE);
    }
    double x, y;
    x = strtod (argv[1], NULL);
    y = strtod (argv[2], NULL);
    printf ("%.2f\n", Pow (x, y));
    return 0;
    }

    The code looks fine to me. But there could be something quite apparent
    that I'm missing. This while linking to the math library too.

    Bill
     
    Bill Cunningham, May 29, 2008
    #1
    1. Advertising

  2. Bill Cunningham

    Guest

    On May 29, 3:54 am, "Bill Cunningham" <> wrote:
    > I have this code and it will not compile telling me that pow is
    > undefined. I'm not quite sure what to make of this so I thought I'd get some
    > feedback.
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include <math.h>
    >
    > int
    > main (int argc, char *argv[])
    > {
    > if (argc != 3)
    > {
    > puts ("usage error");
    > exit (EXIT_FAILURE);
    > }
    > double x, y;
    > x = strtod (argv[1], NULL);
    > y = strtod (argv[2], NULL);
    > printf ("%.2f\n", Pow (x, y));
    > return 0;
    >
    > }
    >
    > The code looks fine to me. But there could be something quite apparent
    > that I'm missing. This while linking to the math library too.

    It should tell you that 'Pow' is undefined, not 'pow'. C's identifiers
    are case sensitive.
     
    , May 29, 2008
    #2
    1. Advertising

  3. "Bill Cunningham" <> writes:
    > I have this code and it will not compile telling me that pow is
    > undefined. I'm not quite sure what to make of this so I thought I'd get some
    > feedback.
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include <math.h>
    >
    > int
    > main (int argc, char *argv[])
    > {
    > if (argc != 3)
    > {
    > puts ("usage error");
    > exit (EXIT_FAILURE);
    > }
    > double x, y;
    > x = strtod (argv[1], NULL);
    > y = strtod (argv[2], NULL);
    > printf ("%.2f\n", Pow (x, y));
    > return 0;
    > }
    >
    > The code looks fine to me. But there could be something quite apparent
    > that I'm missing. This while linking to the math library too.


    It's not telling you that "pow" is undefined.
    It's telling you that "Pow" is undefined.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, May 29, 2008
    #3
  4. <> wrote in message news:59d60972-bef7-4b5b-b9ea-> It
    should tell you that 'Pow' is undefined, not 'pow'. C's identifiers
    > are case sensitive.


    It is. Oh silly me. Thanks. I hate uppercase. It must've been a typo.

    Bill
     
    Bill Cunningham, May 29, 2008
    #4
  5. "Keith Thompson" <> wrote in message
    news:...

    > It's not telling you that "pow" is undefined.
    > It's telling you that "Pow" is undefined.


    > It is. Oh silly me. Thanks. I hate uppercase. It must've been a typo.


    Bill
     
    Bill Cunningham, May 29, 2008
    #5
  6. On Thu, 29 May 2008 00:54:16 GMT, "Bill Cunningham" <>
    wrote:

    > I have this code and it will not compile telling me that pow is
    >undefined. I'm not quite sure what to make of this so I thought I'd get some
    >feedback.


    Since your code never references the pow function, it is unlikely that
    that is what the error message says. Look at it again. Look at it
    carefully. Remember, C is case sensitive. If you still have a
    question, cut and paste the complete text of the error message in your
    message to this newsgroup.

    >
    >#include <stdio.h>
    >#include <stdlib.h>
    >#include <math.h>
    >
    >int
    >main (int argc, char *argv[])
    >{
    > if (argc != 3)
    > {
    > puts ("usage error");
    > exit (EXIT_FAILURE);
    > }
    > double x, y;
    > x = strtod (argv[1], NULL);
    > y = strtod (argv[2], NULL);
    > printf ("%.2f\n", Pow (x, y));
    > return 0;
    >}
    >
    > The code looks fine to me. But there could be something quite apparent
    >that I'm missing. This while linking to the math library too.
    >




    Remove del for email
     
    Barry Schwarz, May 29, 2008
    #6
  7. Bill Cunningham

    Martin Guest

    On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
    <> wrote:
    > Bill Cunningham wrote:
    >> #include <math.h>

    >
    > Should be <Math.h>.
    >
    > ...
    >
    > Glad to be of help, bILL. Good-bye.
    >


    Wouldn't it be more helpful, and save you a lot of typing, if you simply
    told the poster that he had used 'Pow' instead of 'pow' and that C is case
    sensitive? Just like vippstar and Keith Thompson did.

    --
    Martin
     
    Martin, May 29, 2008
    #7
  8. Bill Cunningham

    Richard Guest

    Martin <> writes:

    > On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
    > <> wrote:
    >> Bill Cunningham wrote:
    >>> #include <math.h>

    >>
    >> Should be <Math.h>.
    >>
    >> ...
    >>
    >> Glad to be of help, bILL. Good-bye.
    >>

    >
    > Wouldn't it be more helpful, and save you a lot of typing, if you
    > simply told the poster that he had used 'Pow' instead of 'pow' and
    > that C is case sensitive? Just like vippstar and Keith Thompson did.


    Eric has correctly surmised that Bill is a troll.
     
    Richard, May 29, 2008
    #8
  9. Richard wrote:
    > Martin <> writes:
    >
    >> On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
    >> <> wrote:
    >>> Bill Cunningham wrote:
    >>>> #include <math.h>
    >>>
    >>> Should be <Math.h>.
    >>>
    >>> ...
    >>>
    >>> Glad to be of help, bILL. Good-bye.
    >>>

    >>
    >> Wouldn't it be more helpful, and save you a lot of typing, if you
    >> simply told the poster that he had used 'Pow' instead of 'pow' and
    >> that C is case sensitive? Just like vippstar and Keith Thompson did.

    >
    > Eric has correctly surmised that Bill is a troll.

    But then forgotten not to feed trolls...

    Bye, Jojo
     
    Joachim Schmitz, May 29, 2008
    #9
  10. Bill Cunningham

    Bartc Guest

    "Bill Cunningham" <> wrote in message
    news:Y8n%j.3991$fk.2302@trnddc06...
    > I have this code and it will not compile telling me that pow is
    > undefined. I'm not quite sure what to make of this so I thought I'd get
    > some feedback.
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include <math.h>
    >
    > int
    > main (int argc, char *argv[])
    > {
    > if (argc != 3)
    > {
    > puts ("usage error");
    > exit (EXIT_FAILURE);
    > }
    > double x, y;
    > x = strtod (argv[1], NULL);
    > y = strtod (argv[2], NULL);
    > printf ("%.2f\n", Pow (x, y));
    > return 0;
    > }


    All you have to do is combine the good bits of the above code, and the code
    you posted 3 days ago:

    "Bill Cunningham" <> wrote in message
    news:z3J_j.3440$tF1.560@trnddc01...
    > Is this one of those rare instances where casts are needed? I have this
    > code and the compiler complains that the prototypes are wrong.
    >
    > #include <stdio.h>
    > #include <stdlib.h>
    > #include <math.h>
    >
    > int
    > main (int argc, char *argv[])
    > {
    > if (argc != 4)
    > {
    > puts ("usage error");
    > exit(EXIT_FAILURE);
    > }
    > double x, y;
    > x = strtod (argv[1], NULL);
    > y = strtod (argv[2], NULL);
    > printf ("%.2f\n", pow (argv[1], argv[2]));
    > return 0;
    > }


    --
    Bartc
     
    Bartc, May 29, 2008
    #10
  11. Bill Cunningham

    Richard Guest

    Eric Sosman <> writes:

    > Martin wrote:
    >> On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
    >> <> wrote:
    >>> Bill Cunningham wrote:
    >>>> #include <math.h>
    >>>
    >>> Should be <Math.h>.
    >>>
    >>> ...
    >>>
    >>> Glad to be of help, bILL. Good-bye.
    >>>

    >>
    >> Wouldn't it be more helpful, and save you a lot of typing, if you
    >> simply told the poster that he had used 'Pow' instead of 'pow' and
    >> that C is case sensitive? Just like vippstar and Keith Thompson did.

    >
    > After reading (and sometimes answering) Mister Bill's
    > questions for what seems a long time, I have come around
    > to the opinion that he is not seeking help, but merely
    > response. That is, I think he's trolling.


    The problem is that most of the regs are so obnoxious and rude to new
    posters that they see Bill as a kind of penance and rush to help the
    poor guy with the "learning difficulties". I don't buy it for one minute
    that he can't understand case or that #ifdef's have matching #endifs or
    that brackets determine scope etc. He is most definitely a troll.
     
    Richard, May 29, 2008
    #11
  12. Bill Cunningham

    soscpd Guest

    Hello list, Bill

    I usually try a minimal sample to reproduce the error first, like:

    #include <math.h>

    int main ()
    {
    int x, y;
    Pow(x, y);
    return 0;
    }


    If I can't figure what is going on after that, read the headers
    source, try to access other functions (some header can be out of the
    include's path, who knows?). A little search of source code samples
    over the web (or any sources in your machine who access the same
    headers and still works) helps too (at east, the search can refresh
    your mind and then you can figure the typo. Can happen with anyone).
    If, after that, I still have a question, then, maybe, I can ask around
    on lists or something. Of course, this typo have no reason to be in
    this list (but I think that is completely OT, believe you or not). You
    should update your debug/problem solving skills some way (an you are
    the only one who can figure how to develop that).

    Regards
    Rafael
     
    soscpd, May 29, 2008
    #12
  13. "soscpd" <> wrote in message news:c8cca2dd-aa3f-40c5-989e-
    > If I can't figure what is going on after that, read the headers
    > source, try to access other functions (some header can be out of the
    > include's path, who knows?). A little search of source code samples
    > over the web (or any sources in your machine who access the same
    > headers and still works) helps too (at east, the search can refresh
    > your mind and then you can figure the typo. Can happen with anyone).
    > If, after that, I still have a question, then, maybe, I can ask around
    > on lists or something. Of course, this typo have no reason to be in
    > this list (but I think that is completely OT, believe you or not). You
    > should update your debug/problem solving skills some way (an you are
    > the only one who can figure how to develop that).
    >
    > Regards
    > Rafael


    I completely overlooked the error and (believe it or not ) I thought the
    compiler overlooked case problems anyway so I've learned something today.
    Sometimes I jump the gun and go to clc for help and end up embarrassing
    myself like in this situation. I thought I had a real problem and now I just
    end up with a red face :(

    Bill
     
    Bill Cunningham, May 29, 2008
    #13
  14. Bill Cunningham

    Martin Guest

    On Thu, 29 May 2008 13:08:19 +0100, Eric Sosman
    <> wrote:
    > After reading (and sometimes answering) Mister Bill's
    > questions for what seems a long time, I have come around
    > to the opinion that he is not seeking help, but merely
    > response. That is, I think he's trolling.


    Ah OK. Thanks Eric, I asked and you've answered.

    I wonder if Bill simply posts into clc too quickly, as he's explained
    later. Only he knows. Perhaps he'll learn from the experience.

    --
    Martin
     
    Martin, May 30, 2008
    #14
  15. Bill Cunningham

    Guest

    On May 30, 12:11 pm, Martin <> wrote:
    > On Thu, 29 May 2008 13:08:19 +0100, Eric Sosman
    >
    > <> wrote:
    > > After reading (and sometimes answering) Mister Bill's
    > > questions for what seems a long time, I have come around
    > > to the opinion that he is not seeking help, but merely
    > > response. That is, I think he's trolling.

    >
    > Ah OK. Thanks Eric, I asked and you've answered.
    >
    > I wonder if Bill simply posts into clc too quickly, as he's explained
    > later. Only he knows. Perhaps he'll learn from the experience.

    He's posting newbie and ambiguous questions for 4 years now, or
    perhaps more time.
    It's a troll. Just a troll.
     
    , May 30, 2008
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff S
    Replies:
    1
    Views:
    383
    Scott Allen
    Jan 20, 2004
  2. vMike
    Replies:
    0
    Views:
    319
    vMike
    Jan 23, 2004
  3. =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=

    I completely disagree

    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 2, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    648
    Kevin Spencer
    Jul 6, 2004
  4. Comfort
    Replies:
    1
    Views:
    489
    Enrique Santa Cruz
    Nov 5, 2004
  5. Stephanie
    Replies:
    1
    Views:
    303
    Stephanie
    Jan 13, 2009
Loading...

Share This Page