<p>I have a little routine that's run under Linux and Windows written in C and displays output on the console. I'm not linking in any form of curses or anything like that.</p>

<p>Currently I clear the screen using</p>

<pre><code>#ifdef __WIN32
  system( "cls" );
#else
  system( "clear" );
#endif
</code></pre>

<p>Then I have a bunch of printf statements to update the status. What I'd like just reset the screenpointer to 0,0 so I can then just overlay my printfs. I'd rather avoid compiling in any more extensions especially since I'm coding for 2 different OS'.</p>

[{'answer_id': 56335, 'author': 'Paul Hargreaves', 'author_id': 5330, 'author_profile': 'https://Stackoverflow.com/users/5330', 'pm_score': 1, 'selected': True, 'text': '<p>Looks like I may have found a windows specific way of doing it <a href="http://msdn.microsoft.com/en-us/library/ms686025(VS.85).aspx" rel="nofollow noreferrer">SetConsoleCursorPosition</a></p>\n\n<p>Ansi escape sequence  \\033[0;0H for Linux - just printf that to the console.</p>\n'}, {'answer_id': 56348, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 1, 'selected': False, 'text': '<p>For Unix-like platforms, the usual way to do this is using the <a href="http://en.wikipedia.org/wiki/Curses_(programming_library)" rel="nofollow noreferrer">curses</a> library.</p>\n'}, {'answer_id': 98562, 'author': 'wnoise', 'author_id': 15464, 'author_profile': 'https://Stackoverflow.com/users/15464', 'pm_score': 0, 'selected': False, 'text': '<p>Yes, for unix platforms, curses (or ncurses, these days) is the way to go.  And there are versions that work under windows, so you could do it the same way on both systems.</p>\n'}, {'answer_id': 425208, 'author': 'seanyboy', 'author_id': 1726, 'author_profile': 'https://Stackoverflow.com/users/1726', 'pm_score': 0, 'selected': False, 'text': '<p>For windows - You can use ANSI escape characters. </p>\n\n<p><a href="http://www.lexipixel.com/news/star_dot_star/using_ansi_escape_sequences.htm" rel="nofollow noreferrer">http://www.lexipixel.com/news/star_dot_star/using_ansi_escape_sequences.htm</a>  </p>\n\n<p><a href="http://www.robvanderwoude.com/ansi.html" rel="nofollow noreferrer">http://www.robvanderwoude.com/ansi.html</a>  </p>\n\n<pre><code>printf "\\x[0;0H"\n</code></pre>\n\n<p>It used to be that Ansi.sys needed to be loaded before you could do this, but it\'s worth a shot. </p>\n\n<p>Instructions for adding ANSI support \n<a href="http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/UserTips/CommandPrompt/CommandInterpreterAnsiSupport.html" rel="nofollow noreferrer">http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/UserTips/CommandPrompt/CommandInterpreterAnsiSupport.html</a>\nNote: that Ansi.sys only works under command.com. You can\'t use it with cmd.exe</p>\n'}]
['https://Stackoverflow.com/questions/56324', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5330/']