How can you edit the std::cin delim char?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Snast

    How can you edit the std::cin delim char?

    hello guys

    I need to modify the std::cin delim char from the default ' ' and '\n'
    characters to ',' i know that i can edit the delim in the getline
    command however i'd like to know if there's something build in with me
    having to overload the std::cin operator

    thanks, Alex Snast.
  • Jerry Coffin

    #2
    Re: How can you edit the std::cin delim char?

    In article <91ee4eb9-768d-4db2-99b2-a9132f6646a8
    @z66g2000hsc.go oglegroups.com> , asnast@gmail.co m says...
    hello guys
    >
    I need to modify the std::cin delim char from the default ' ' and '\n'
    characters to ',' i know that i can edit the delim in the getline
    command however i'd like to know if there's something build in with me
    having to overload the std::cin operator
    There are a couple of possibilities. The delimiters are defined by the
    locale, so you can define a new locale with the delimiters of your
    choice.

    You can also create a filtering streambuf to transform the input into a
    format that's easier to deal with (e.g. take the commas in the original
    input and replace them with spaces so the rest of the code only sees the
    spaces that the iostream expects to use as delimiters.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

    Comment

    • Alex Snast

      #3
      Re: How can you edit the std::cin delim char?



      Jerry Coffin כתב:
      In article <91ee4eb9-768d-4db2-99b2-a9132f6646a8
      @z66g2000hsc.go oglegroups.com> , asnast@gmail.co m says...
      hello guys

      I need to modify the std::cin delim char from the default ' ' and '\n'
      characters to ',' i know that i can edit the delim in the getline
      command however i'd like to know if there's something build in with me
      having to overload the std::cin operator
      >
      There are a couple of possibilities. The delimiters are defined by the
      locale, so you can define a new locale with the delimiters of your
      choice.
      >
      You can also create a filtering streambuf to transform the input into a
      format that's easier to deal with (e.g. take the commas in the original
      input and replace them with spaces so the rest of the code only sees the
      spaces that the iostream expects to use as delimiters.
      >
      --
      Later,
      Jerry.
      >
      The universe is a figment of its own imagination
      How do i do it. can you show me a code example please.

      Comment

      • Jerry Coffin

        #4
        Re: How can you edit the std::cin delim char?

        In article <851d9b3b-1783-4585-8368-6a14f2c1fa87
        @a70g2000hsh.go oglegroups.com> , asnast@gmail.co m says...
        How do i do it. can you show me a code example please.

        c++/browse_frm/thread/9ee70fc9a0fffa1 c/c9daefcb5147bb1 9#c9daefcb5147b b19

        Has one example.

        --
        Later,
        Jerry.

        The universe is a figment of its own imagination.

        Comment

        Working...