| | |
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: 72
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,842
Reputation:
Solved Threads: 503
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: 604
Reputation:
Solved Threads: 79
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
Views: 145 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll dynamic encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort stream string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






