|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On May 29, 3:54 am, "Bill Cunningham" <nos...@nspam.com> 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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"Bill Cunningham" <nospam@nspam.com> 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) 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" |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
<vippstar@gmail.com> 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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
"Keith Thompson" <kst-u@mib.org> wrote in message news:ln1w3loqxd.fsf@nuthaus.mib.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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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_Failure); > } > 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 , bILL. Good-bye. -- Eric Sosman esosman@ieee-dot-org.invalid |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Thu, 29 May 2008 00:54:16 GMT, "Bill Cunningham" <nospam@nspam.com>
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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote: > Bill Cunningham wrote: >> #include <math.h> > > Should be <Math.h>. > > ... > > Glad to be of , bILL. Good-bye. > Wouldn't it be more ful, 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 |
|
![]() |
| Outils de la discussion | |
|
|