what to use to accept both characters and digits together in turboC

Discussion in 'C++' started by dreand14, Sep 6, 2010.

  1. dreand14

    dreand14 New Member

    Joined:
    Sep 6, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    example output:


    Meter number is: 124123ABC231


    "what should i use to define something like that....


    TurboC newbie here...
     
  2. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    using a character array or std::string...
    Here are the examples:-

    Code:
    char mnumber[255];
    printf("Enter an item number\n");
    fgets(mnumber,sizeof(mnumber), stdin);
    if( mnumber[strlen(mnumber)-1] == '\n')
       mnumber[strlen(mnumber)-1] = '\0';
    printf("Meter number is: %s\n", mnumber);
    
    Code:
    std::string mnumber;
    cout << "Enter an item number\n";
    getline(cin,mnumber);
    cout << "Meter number is: " << mnumber << '\n';
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice