|
-
February 17th, 2012, 04:39 AM
#16
Re: How to generate an auto ID (or Auto Number)
 Originally Posted by general07z
The ID in my code is defined as a "Phone Number", as showing here:
If you want to store a phone number, then declare your variable as "Phone_Number"!
"as shown here": We can only read so much code to try to understand what you are doing. We can't read your mind.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
February 17th, 2012, 09:58 AM
#17
Re: How to generate an auto ID (or Auto Number)
 Originally Posted by monarch_dodra
If you want to store a phone number, then declare your variable as "Phone_Number"!
"as shown here": We can only read so much code to try to understand what you are doing. We can't read your mind.
Yes that is true,
So i hope to change that variable to make it for generating an ID. i don't want any more "Phone number" Generating the Auto ID is more important than Phone number.
So now the program shouldn't ask for entering the ID, directly when the patient is successfully added the Auto ID should appear with the entered information.
for example:
First Name:
John
Last Name:
Jobs
ID:
001
Regards
-
February 17th, 2012, 11:10 AM
#18
Re: How to generate an auto ID (or Auto Number)
So why not just go to the end of your queue, or what ever your container is, look up the last ID and add 1 to it?
Does this data need to be persistent between runs of the program?
-
February 17th, 2012, 12:21 PM
#19
Re: How to generate an auto ID (or Auto Number)
 Originally Posted by GCDEF
So why not just go to the end of your queue, or what ever your container is, look up the last ID and add 1 to it?
Does this data need to be persistent between runs of the program?
Hey,
How can i do that?
Is your idea, the number will be auto increase when i added another patient?
If yes, Please where do i have to change in my code.
I just need the ID to be increasing when i added another patient
like the first patient will have ID number 1
the second patient will have number 2.........
So i don't want the the program to ask me for Entering ID.
But when i add it. he should have the ID.
Thanks
Last edited by general07z; February 17th, 2012 at 12:35 PM.
-
February 17th, 2012, 01:09 PM
#20
Re: How to generate an auto ID (or Auto Number)
Hey,
I have added
Code:
int main(){
int Auto_ID =0;
}
than Added
Code:
cout<<"ID"<<p.Auto_ID++<<endl;
but it showing me an error
Code:
"see declaration of 'main'"
I just need the easiest way to make this ID works
Thanks
-
February 17th, 2012, 01:18 PM
#21
Re: How to generate an auto ID (or Auto Number)
 Originally Posted by general07z
Hey,
I have added
Code:
int main(){
[hl]int Auto_ID[/hl =0;
}
than Added
Code:
cout<<"ID"<<p.Auto_ID++<<endl;
but it showing me an error
Code:
"see declaration of 'main'"
And What is "p" in this context?
Victor Nijegorodov
-
February 17th, 2012, 02:32 PM
#22
Re: How to generate an auto ID (or Auto Number)
hey, it is a pointer
Code:
// define class for queue
class queue
{
public:
queue (void);
int RegisterPatien (patient p);
int RegisterPatientAtBeginning (patient p);
patient GetNextPatient (void);
int CancelAll (patient * p);
void OutputList (void);
char DepartmentName[50];
private:
int ShowAllPatient;
patient List[MAXPATIENTS];
};
So what is the problem with:
Code:
int main(){
int Auto_ID =0;
}
Is there any other method to do auto-increment number?
Last edited by general07z; February 17th, 2012 at 02:57 PM.
-
May 27th, 2012, 11:48 AM
#23
Re: How to generate an auto ID (or Auto Number)
HI friends I'm actually new to C++..and wanted to know how to add a auto numbering code to my First ever program..guys would you mind helping me..how should this be coded?
-
May 27th, 2012, 11:57 AM
#24
Re: How to generate an auto ID (or Auto Number)
What is "a auto numbering code"?
What is it supposed to do?
Victor Nijegorodov
-
May 27th, 2012, 11:59 AM
#25
Re: How to generate an auto ID (or Auto Number)
Well its suppose to increase the number..example: 1st Customer ID would be Cust001, 2nd Customer Id would be Cust002..
-
May 27th, 2012, 12:03 PM
#26
Re: How to generate an auto ID (or Auto Number)
actually this is for a Bank and when a new member is added his/her Bank Number should be delivered automatically..example:
Account Number: 001 //this should be automatically generated
Name : J_Freak //the person has to type
Age : 21 //the person has to type
so on....
-
May 27th, 2012, 12:08 PM
#27
Re: How to generate an auto ID (or Auto Number)
If it "or a Bank" then you should (maybe just must!) use some type of database. And a database will generate all these IDs for you for each new added account.
Victor Nijegorodov
-
May 27th, 2012, 12:15 PM
#28
Re: How to generate an auto ID (or Auto Number)
Well this is really really a basic "BASIC" programming..just a console application with 4 options (New account, Withdraw, Deposit & Balance inquiry) and some basic validations..so when the "New account" is selected the user must be able to fill the application..and the account number should be generated automatically..and the details will be saved in a notepad..
Account Number: 001 //this should be automatically generated
Name : J_Freak //the person has to type
Age : 21 //the person has to type
So..I actually need to know how to do this "auto numbering" thinggy...
-
May 27th, 2012, 12:20 PM
#29
Re: How to generate an auto ID (or Auto Number)
Are you going to supply such a "a basic "BASIC" ... console application with 4 options" to some Bank?
As for "auto numbering" in a real application (not just a a basic "BASIC" one) - see my previous post.
Victor Nijegorodov
-
May 27th, 2012, 12:22 PM
#30
Re: How to generate an auto ID (or Auto Number)
Nah nah..just a basic program for my school project..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|