completely stuck

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Cunningham

    completely stuck

    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


  • vippstar@gmail.com

    #2
    Re: completely stuck

    On May 29, 3:54 am, "Bill Cunningham" <nos...@nspam.c omwrote:
    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.

    Comment

    • Keith Thompson

      #3
      Re: completely stuck

      "Bill Cunningham" <nospam@nspam.c omwrites:
      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_Keit h) kst-u@mib.org <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"

      Comment

      • Bill Cunningham

        #4
        Re: completely stuck


        <vippstar@gmail .comwrote 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


        Comment

        • Bill Cunningham

          #5
          Re: completely stuck


          "Keith Thompson" <kst-u@mib.orgwrote in message
          news:ln1w3loqxd .fsf@nuthaus.mi b.org...
          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


          Comment

          • Eric Sosman

            #6
            Re: completely stuck

            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>
            Should be <Math.h>.
            int
            main (int argc, char *argv[])
            Should be Int Main.
            {
            if (argc != 3)
            {
            puts ("usage error");
            ITYM Puts.
            exit (EXIT_FAILURE);
            ITYM Exit(exit_Failu re);
            }
            double x, y;
            Should be DOUBLE.
            x = strtod (argv[1], NULL);
            y = strtod (argv[2], NULL);
            Should be StrtOD ... null in both instances.
            printf ("%.2f\n", Pow (x, y));
            Should be Printf ... poW(...)
            return 0;
            Should be Return Zero;
            }
            >
            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
            Glad to be of help, bILL. Good-bye.

            --
            Eric Sosman
            esosman@ieee-dot-org.invalid

            Comment

            • Barry Schwarz

              #7
              Re: completely stuck

              On Thu, 29 May 2008 00:54:16 GMT, "Bill Cunningham" <nospam@nspam.c om>
              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

              Comment

              • Martin

                #8
                Re: completely stuck

                On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
                <esosman@ieee-dot-org.invalidwrot e:
                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

                Comment

                • Richard

                  #9
                  Re: completely stuck

                  Martin <m@b.cwrites:
                  On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
                  <esosman@ieee-dot-org.invalidwrot e:
                  >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.

                  Comment

                  • Joachim Schmitz

                    #10
                    Re: completely stuck

                    Richard wrote:
                    Martin <m@b.cwrites:
                    >
                    >On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
                    ><esosman@iee e-dot-org.invalidwrot e:
                    >>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


                    Comment

                    • Bartc

                      #11
                      Re: completely stuck


                      "Bill Cunningham" <nospam@nspam.c omwrote in message
                      news:Y8n%j.3991 $fk.2302@trnddc 06...
                      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" <nospam@nspam.c omwrote in message
                      news:z3J_j.3440 $tF1.560@trnddc 01...
                      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_FAILU RE);
                      }
                      double x, y;
                      x = strtod (argv[1], NULL);
                      y = strtod (argv[2], NULL);
                      printf ("%.2f\n", pow (argv[1], argv[2]));
                      return 0;
                      }
                      --
                      Bartc


                      Comment

                      • Eric Sosman

                        #12
                        Re: completely stuck

                        Martin wrote:
                        On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
                        <esosman@ieee-dot-org.invalidwrot e:
                        >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.

                        --
                        Eric Sosman
                        esosman@ieee-dot-org.invalid

                        Comment

                        • Richard

                          #13
                          Re: completely stuck

                          Eric Sosman <esosman@ieee-dot-org.invalidwrit es:
                          Martin wrote:
                          >On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
                          ><esosman@iee e-dot-org.invalidwrot e:
                          >>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.

                          Comment

                          • soscpd

                            #14
                            Re: completely stuck

                            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

                            Comment

                            • Bill Cunningham

                              #15
                              Re: completely stuck


                              "soscpd" <soscpd@gmail.c omwrote 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


                              Comment

                              Working...