string question

Discussion in 'C++' started by Huub, May 8, 2011.

  1. Huub

    Huub Guest

    Hi,

    I try to read a string command from commandline using cin.getline
    (command, 14). This works fine, but somehow there's some input given
    before the first command is typed in. I know this because there's already
    response while it should be waiting for the first command. How can I make
    sure this doesn't happen?

    Thanks
     
    Huub, May 8, 2011
    #1
    1. Advertising

  2. Huub

    osmium Guest

    "Huub" wrote:

    > I try to read a string command from commandline using cin.getline
    > (command, 14). This works fine, but somehow there's some input given
    > before the first command is typed in. I know this because there's already
    > response while it should be waiting for the first command. How can I make
    > sure this doesn't happen?


    Use ios::ignore() before the query for response.
     
    osmium, May 8, 2011
    #2
    1. Advertising

  3. Huub

    Huub Guest

    On Sun, 08 May 2011 12:48:33 -0500, osmium wrote:

    > "Huub" wrote:
    >
    >> I try to read a string command from commandline using cin.getline
    >> (command, 14). This works fine, but somehow there's some input given
    >> before the first command is typed in. I know this because there's
    >> already response while it should be waiting for the first command. How
    >> can I make sure this doesn't happen?

    >
    > Use ios::ignore() before the query for response.


    Thank you. That works.
     
    Huub, May 8, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mladen Adamovic
    Replies:
    0
    Views:
    742
    Mladen Adamovic
    Dec 4, 2003
  2. Mladen Adamovic
    Replies:
    3
    Views:
    14,622
    Mladen Adamovic
    Dec 5, 2003
  3. Matt
    Replies:
    3
    Views:
    510
    Tor Iver Wilhelmsen
    Sep 17, 2004
  4. Bruce Sam
    Replies:
    15
    Views:
    7,934
    John C. Bollinger
    Nov 19, 2004
  5. =?Utf-8?B?UmFqZXNoIHNvbmk=?=

    'System.String[]' from its string representation 'String[] Array'

    =?Utf-8?B?UmFqZXNoIHNvbmk=?=, May 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,803
    =?Utf-8?B?UmFqZXNoIHNvbmk=?=
    May 4, 2006
Loading...

Share This Page