1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    17
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    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