PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > completely stuck
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
completely stuck

Réponse
 
LinkBack Outils de la discussion
Vieux 29/05/2008, 01h54   #1
Bill Cunningham
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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


  Réponse avec citation
Vieux 29/05/2008, 02h06   #2
vippstar@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: completely stuck

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.
  Réponse avec citation
Vieux 29/05/2008, 02h11   #3
Keith Thompson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: completely stuck

"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"
  Réponse avec citation
Vieux 29/05/2008, 02h24   #4
Bill Cunningham
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: completely stuck


<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


  Réponse avec citation
Vieux 29/05/2008, 02h25   #5
Bill Cunningham
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: completely stuck


"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


  Réponse avec citation
Vieux 29/05/2008, 02h26   #6
Eric Sosman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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_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
  Réponse avec citation
Vieux 29/05/2008, 03h02   #7
Barry Schwarz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: completely stuck

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
  Réponse avec citation
Vieux 29/05/2008, 10h31   #8
Martin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: completely stuck

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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h54.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19822 seconds with 16 queries