| | |
is that possible i'm using this substring to determine age from id?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 59
Reputation:
Solved Threads: 1
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...
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...
C++ Syntax (Toggle Plain Text)
#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; }
•
•
Join Date: Jan 2008
Posts: 3,829
Reputation:
Solved Threads: 501
0
#2 Nov 3rd, 2009
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.
What are you trying to do here?
idnum.subint (0,2);What are you trying to do here?
Last edited by VernonDozier; Nov 3rd, 2009 at 12:37 am.
•
•
Join Date: Sep 2009
Posts: 455
Reputation:
Solved Threads: 52
0
#3 Nov 3rd, 2009
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.
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.
![]() |
Similar Threads
- Identify someone's age by entering the IC number... (C++)
- String Parsing using known delimiters? [C++] (C++)
- Page and Link Age - Older is better but... (Search Engine Optimization)
- Domain age? (Search Engine Optimization)
- My page won't load on Macs (HTML and CSS)
- News Story: Software identifies potential pedophiles online (Graphics and Multimedia)
- Match making scripts (PHP)
- Update to completly lost : ) (Java)
Other Threads in the C++ Forum
- Previous Thread: Please someone help me with these 19 errors !!!
- Next Thread: Ask about program
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






