Forcing astring onto the same line

This is a discussion on Forcing astring onto the same line within the C++ Programming forums, part of the General Programming Boards category; Hi I am new to this so forgive me if this has been asked but does anybody know a character ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    1

    Forcing astring onto the same line

    Hi I am new to this so forgive me if this has been asked but does anybody know a character similiar to the \n to force and output line back onto the line above. The problem I have is I am doing a user input followed by a comma followed by another user input co-ordinates obv, but it will only pull over 2 lines?e.g.
    enter next move?
    5
    ,6
    I am trying to force it on the same line but cannot anyone got any suggestions?

    Thanks Dave

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You can never go backwards. But: in this case it appears to be the user's fault, not your fault. I mean, if you ask them to type "5,6" and they type "5[enter],6" there's nothing you can do about it.

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You could probably use getline, parse that and "punish" the user unless they type things the way you like with prompting again, closing the program etc. That would not give them a choice but to enter things on the same line.

    But is it worth it?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    if you are using windows you can make a gotoxy(int,int) function. This would allow you to go backwards, but it is obviously very platform dependent.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do encryption in C
    By sankarv in forum C Programming
    Replies: 33
    Last Post: 12-28-2010, 10:01 AM
  2. Pointer and Polymorphism help.
    By Skyy in forum C++ Programming
    Replies: 29
    Last Post: 12-18-2008, 08:17 PM
  3. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 03:13 PM
  4. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 05:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21