NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Simple C questions

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 05-07-2006, 07:02 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



Simple C questions


How do you find if a certain number is an integer or not? I am trying to make a simple C console application, so any help would be appreciated. Also, how do you display a variable, for example a variable called num (also in the same console application)? I really can't find a thing on the web to help me, so I have turned to the programming gurus of namepros. Please help!
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 05-07-2006, 08:40 PM THREAD STARTER               #2 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



anyone?
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 05-08-2006, 03:52 AM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



No one knows C?
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 05-08-2006, 03:58 AM   #4 (permalink)
NamePros Legend
 
weblord's Avatar
Join Date: Dec 2005
Location: Philippines - www.Nabaza.com
Posts: 19,785
weblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatness
 


Autism Protect Our Planet
some C guides/references for you:
http://www.cppreference.com/
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

some for variables and characters and integers:
http://www.acm.uiuc.edu/webmonkeys/b...html#variables
__________________
Nabaza.com - Amaia
weblord is offline  
Old 05-08-2006, 04:12 AM THREAD STARTER               #5 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



thanks, I got displaying the variable working now, but I still can't seem to get any information on checking if a number is an integer or not... Rep added (or would add Rep, except I have to spread it... )!

Anyone else have any information?
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 05-08-2006, 06:46 AM   #6 (permalink)
 
BillyConnite's Avatar
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,456
BillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond repute
 


Wildlife Parkinson's Disease Parkinson's Disease
Well not too experienced in C myself

But I think you might be looking for something like this?:
Quote:
// typeid
????: NamePros.com http://www.namepros.com/programming/194796-simple-c-questions.html
#include <iostream>
#include <typeinfo>
using namespace std;

int main () {
int * a,b;
a=0; b=0;
if (typeid(a) != typeid(b))
{
cout << "a and b are of different types:\n";
cout << "a is: " << typeid(a).name() << '\n';
cout << "b is: " << typeid(b).name() << '\n';
}
return 0;
}
Not sure if you'll have those headers though (if that's how it works lol) taken from: http://www.cplusplus.com/doc/tutorial/typecasting.html

Hope it helps,
Rhett.
BillyConnite is offline  
Old 05-08-2006, 08:00 AM THREAD STARTER               #7 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



looks like C++ to me... ah well, I'll give it a try (later, when I have time), although I don't really follow the code. Rep added!
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 05-09-2006, 04:41 AM THREAD STARTER               #8 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



anybody else have any suggestions?
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 05-09-2006, 11:17 AM   #9 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



I'm a little confused as in theory, if the datatype of the number is 'int', then naturally you have an int
????: NamePros.com http://www.namepros.com/showthread.php?t=194796

Where did this number come from? Is your situation something like "I have a double or a float and want to know if it has nothing after the decimal place?"

If so... I'd look at casting the number to an int then compare it to the original number.

eg.
Code:
double d = 0; // this is the number you want to check
int i = (int) d;

if ((d - i) != 0) {
     // the number had something after the decimal place
} else {
    // the number had nothing after the decimal place
}
Although that doesn't work always because of the fact that doubles and floats aren't very 'precise'.

If you have access to math.h, you could try:
Code:
double d = 0; // this is the number you want to check

if (fmod(d, 1) != 0) {
     // the number had something after the decimal place
} else {
    // the number had nothing after the decimal place
}
Well, that's what I'd look at doing, anyway...
TwistMyArm is offline  
Old 05-09-2006, 03:57 PM THREAD STARTER               #10 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



wow, gee thanks! That looks like EXACTLY what I needed! I'll give it a try! Rep added!
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:10 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger