i'm trying to determine the age of the people by entering their id card number..i'm trying to do this without having the database..
is this code possible??because i got error when try to run it..
if this possible,could you tell me the correct way to do this?

Thanks...

#include <iostream>
#include <string>
using namespace std;

int main()
{
int idnum,age,yearbirth;

cout << "enter id number: ";
cin >> idnum;

yearbirth=idnum.subint (0,2);

age=2009-yearbirth

cout << age;

}

I think you need to give an example. What's idnum? How does one determine yearbirth from idnum? idnum is an int. There's no "int" class, so the dot operator won't work.

idnum.subint (0,2)[B];[/B]

What are you trying to do here?

There's no such thing as subint to my knowledge.
Take in the ID as a string, do a substr(0,2), convert that truncated string to an integer (using atoi). There's a slight flaw in your ID scheme though since if the digits are 00-09 the person could be 100 or just born. You need to do your subtraction by adding to your year value so it gives the right age.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.