Computing.Net > Forums > Programming > Where's the TRUNC func? (C++)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Where's the TRUNC func? (C++)

Reply to Message Icon

Name: Leo the 28C (by Sulfurik)
Date: September 4, 2005 at 15:41:31 Pacific
OS: Windows XP Home SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello everyone! :D
OK, I read on a forum post that there was a "trunc" function in the "std lib" that removed decimal points off numbers... The problem is that this function doesn't exist!

Look at my code:

----------
#include <iostream.h>
#include <stdlib.h>

int main()
{
int age; // Age variable
cout << "Hello there!\n";
cout << "Please type in your age: ";
cin >> age;
cout << "Good, good... You'll die when you're " << trunc(age * 1.5) << " years old! HAHAHA!!!";
}
----------

That function doesn't exist! I searched for it at http://www.cplusplus.com/ref/ but I didn't find it... Is there a FULL library reference out there that I can use? Can anyone help me? Thanks! ;)

PS#1: The forum post:
http://forums.devarticles.com/t10032/s.html

PS#2: I'm using Borland's free C++ compiler.

PS#3: I hope not to die at the age the program told me...

http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D



Sponsored Link
Ads by Google

Response Number 1
Name: gimmpy225
Date: September 4, 2005 at 17:17:38 Pacific
Reply:

trunc is part of the ms visual C++ lib i think, not sure though so dont hold me to it.

GIMPS


0

Response Number 2
Name: gimmpy225
Date: September 4, 2005 at 17:20:06 Pacific
Reply:

ios::trunc If the file already existed it is erased

found that for C++

GIMPS


0

Response Number 3
Name: Leo the 28C (by Sulfurik)
Date: September 4, 2005 at 18:17:22 Pacific
Reply:

Yeah, it probably was for VC++... Thanks! ;)

http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D


0

Response Number 4
Name: syvjackson
Date: September 5, 2005 at 20:09:47 Pacific
Reply:

This is for Rimfire! Nothing seems to be working. I'm ready now to throw in the towl and take this thing to someone smarter than I. Thanks for all your help, your wonderful patience and time. You guys are great.
syvjackson


0

Response Number 5
Name: gimmpy225
Date: September 5, 2005 at 21:32:19 Pacific
Reply:

what ya having problems with syv, sry for using your post to talk sulfur lol

GIMPS


0

Related Posts

See More



Response Number 6
Name: timmay024
Date: September 27, 2005 at 09:17:03 Pacific
Reply:

This might be kind of late but if you want to take a number like 123.456 and just get rid of the .456 then you can declare a int and set it equal to your decimal.


int num;
double dec = 123.45;

num = dec;
cout << num;
will give 123


0

Sponsored Link
Ads by Google
Reply to Message Icon

Bug Hunt help plz How to read whole file? (...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Where's the TRUNC func? (C++)

FRONTPAGE 2000 - Where's the TUTORI www.computing.net/answers/programming/frontpage-2000-wheres-the-tutori/3261.html

Here's the code... Please Help!!! www.computing.net/answers/programming/heres-the-code-please-help/1886.html

where can I downl. turbo c 3.0 or best www.computing.net/answers/programming/where-can-i-downl-turbo-c-30-or-best-/418.html