Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > completely stuck

Reply
Thread Tools

completely stuck

 
 
Bill Cunningham
Guest
Posts: n/a
 
      05-29-2008
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


 
Reply With Quote
 
 
 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      05-29-2008
On May 29, 3:54 am, "Bill Cunningham" <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      05-29-2008
"Bill Cunningham" <(E-Mail Removed)> 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.velocityreviews.com/forums/(E-Mail Removed) <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"
 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      05-29-2008

<(E-Mail Removed)> 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


 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      05-29-2008

"Keith Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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


 
Reply With Quote
 
Barry Schwarz
Guest
Posts: n/a
 
      05-29-2008
On Thu, 29 May 2008 00:54:16 GMT, "Bill Cunningham" <(E-Mail Removed)>
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
 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      05-29-2008
On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
<(E-Mail Removed)> 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

 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      05-29-2008
Martin <(E-Mail Removed)> writes:

> On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
> <(E-Mail Removed)> 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.
 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      05-29-2008
Richard wrote:
> Martin <(E-Mail Removed)> writes:
>
>> On Thu, 29 May 2008 02:26:47 +0100, Eric Sosman
>> <(E-Mail Removed)> 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


 
Reply With Quote
 
Bartc
Guest
Posts: n/a
 
      05-29-2008

"Bill Cunningham" <(E-Mail Removed)> 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" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
completely stuck on fileupload in griidview Stephanie ASP .Net 1 01-13-2009 06:04 PM
Re: VOIPfone down completely ... I mean very completely !! cjd UK VOIP 2 10-10-2008 01:17 PM
Re: Newbie, Cisco 877, ipv6, IOS, completely stuck News Reader Cisco 10 04-19-2008 04:51 PM
Etching tutorials-or now for something completely different Technoholic Case Modding 71 09-27-2005 06:39 AM
Completely stuck with new Shuttle computer... SR Computer Support 25 11-03-2003 02:23 AM



Advertisments