going back to previous line

This is a discussion on going back to previous line within the C Programming forums, part of the General Programming Boards category; In c we use \n for the next line. Is there any way to go to previous line?...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    2

    going back to previous line

    In c we use \n for the next line. Is there any way to go to previous line?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    No, \n simply means line-feed, ie there is a new-line following (punctuation). You'd have to rewind back to the last line-feed.

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    If you u trying to do something like that in the console, then there are no way to go back to the previous line, unless if you are working on files either you could use fseek or rewind to go back to top of the file and work around to come back to the appropriate line.

    ssharish2005

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    You might try \v

    Though to be honest, if you need a lot of random positioning of the cursor on a console screen, it would be much better to use a library such as ncurses.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    2
    I have tried \v. But it printed only as special symbol. Will you please tell me how to use that library ncurses?

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    Is there something wrong with the existing ncurses documentation, FAQ and tutorial sites?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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. How to go to a previous line
    By Megamanenm in forum C++ Programming
    Replies: 1
    Last Post: 04-14-2009, 06:49 PM
  3. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  4. Very strange error...
    By Blackroot in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2006, 12:37 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

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