completely stuck

B

Bill Cunningham

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
 
V

vippstar

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.
 
K

Keith Thompson

Bill Cunningham said:
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.
 
B

Barry Schwarz

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
 
M

Martin

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.
 
R

Richard

Martin said:
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.
 
B

Bartc

Bill Cunningham said:
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 said:
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;
}
 
R

Richard

Eric Sosman said:
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.
 
S

soscpd

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
 
B

Bill Cunningham

soscpd said:
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
 
M

Martin

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.
 
V

vippstar

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top