Results 1 to 19 of 19

Thread: #include "cmath.h"

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    #include "cmath.h"

    it's givin error about cmath.h...but why?!?

    Code:
    // troll1.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "iostream.h"
    #include "cmath.h"
    
    using namespace std;
    
    void main()
    {
    	int cateto1, cateto2;
    	cout << "Calcular a hipotenusa de um um triângulo sendo dados os seus catetos:\nCateto 1: ";
    	cin >> cateto1;
    	cout << "Cateto 2: ";
    	cin >> cateto2;
    	count << "A hipotenusa é" << hipotenusa(cateto1, cateto2);
    }
    
    int hipotenusa(int cateto1, int cateto2)
    {
    	cateto1 = cateto1^2;
    	cateto2 = cateto2^2;
    
    	return sqtr(cateto1 + cateto2);
    }
    \m/\m/

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    maybe math.h?
    squareroot is sqrt() not sqtr(), power is pow() although you can get away with cateto1*cateto1 resp..
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169

    Re: #include "cmath.h"

    Originally posted by PT Exorcist
    it's givin error about cmath.h...but why?!?

    Code:
    #include <iostream>
    #include <cmath>
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    no the problem is cmath...what should i do?

    ...
    \m/\m/

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    cmath.h doesn't exist. math.h is the C-header, cmath is the C++ version. cmath.h is nothing.
    As parksie wrote, and don't forget that everything is in the std namespace.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    but my vc6++ compiler doesnt allow the include's without the extension!
    \m/\m/

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    omg tryed with math.h and worked...but shouldnt be this have a cmath.h? u said the C has math.h and c++ has cmath.h..
    \m/\m/

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    No. It's math.h and cmath. No extension.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    but if i put without extension i get error in the compiler!
    \m/\m/

  10. #10

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    damn im getting mad so many differences between what the book says and what i must do with vc6++...is borland's c++ best?
    \m/\m/

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Visual C++ 6 supports cmath. At least it *should*, since v5 did. Personally, I think Microsoft's compiler absolutely trashes Borland's.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  12. #12

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    but mine didnt...i think ill ask to some friend for his cd to see if theres any difference or somewhat :\
    \m/\m/

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Even my introductory edition of VC++6 supported <cmath>. And that's the smallest edition you can get (it was free).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  14. #14
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    Are you using:

    Code:
    #include <cmath>
    or...

    Code:
    #include "cmath"
    It shouldn't matter - but it might...

    I can't see why cmath wouldn't work - works fine for me on VC++ 6.

    HD

  15. #15

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    tryed the two ways right now and none of the works..just works with " " s and extension..maybe that's happening beacuse this is a riped version or something like that
    \m/\m/

  16. #16
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    What error do you get than? And you're sure your including
    using namespace std also? Also make sure the include paths of your compiler are right.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  17. #17

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    where should they point to?
    \m/\m/

  18. #18
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    <vc++maindir>\include
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  19. #19

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yea it has math.h...but its confusing..because this should have cmath....bah
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width