CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 36
  1. #16
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: How to generate an auto ID (or Auto Number)

    Quote Originally Posted by general07z View Post
    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.

  2. #17
    Join Date
    Feb 2012
    Posts
    17

    Re: How to generate an auto ID (or Auto Number)

    Quote Originally Posted by monarch_dodra View Post
    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

  3. #18
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    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?

  4. #19
    Join Date
    Feb 2012
    Posts
    17

    Re: How to generate an auto ID (or Auto Number)

    Quote Originally Posted by GCDEF View Post
    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.

  5. #20
    Join Date
    Feb 2012
    Posts
    17

    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

  6. #21
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How to generate an auto ID (or Auto Number)

    Quote Originally Posted by general07z View Post
    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

  7. #22
    Join Date
    Feb 2012
    Posts
    17

    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.

  8. #23
    Join Date
    May 2012
    Posts
    8

    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?

  9. #24
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How to generate an auto ID (or Auto Number)

    What is "a auto numbering code"?
    What is it supposed to do?
    Victor Nijegorodov

  10. #25
    Join Date
    May 2012
    Posts
    8

    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..

  11. #26
    Join Date
    May 2012
    Posts
    8

    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....

  12. #27
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    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

  13. #28
    Join Date
    May 2012
    Posts
    8

    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...

  14. #29
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    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

  15. #30
    Join Date
    May 2012
    Posts
    8

    Re: How to generate an auto ID (or Auto Number)

    Nah nah..just a basic program for my school project..

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured