Using Curses to  on Console

Posted on 2006-05-13
Last Modified: 2010-04-15
Hi experts,

Need help on using curses (or whatever it is that you are ment to use) to make boarders on a unix console.

something that looks like:


its a basis for a game. But I dont know how to implement this.

Question by:Omer_85
    LVL 45

    Expert Comment

    Hi Omer_85,

    You can always download a linux distribution and extract the curses source.

    If you want to do it the "hard way" you'll have to map out each character and build a bitmap for them.  It's a lot of tedious work.

    Good Luck!
    LVL 23

    Expert Comment

    Use getmaxyx() [or the LINES and COLUMNS global variables] to determine the number of lines and columns on the console window.  [Remember that the coordindates are 0-relative.]

    Use move() to position the cursor for writing.

    Use addch() or addstr() to write a character or string at the current cursor position.

    Use refresh() to flush the output to the screen.

    For more information, see this tutorial:

    Author Comment

    Thanks for the comments guys..

    Kent I've got no idea about Linux..

    Brett I think your way sounds like the way to do it.. Just because I can use a UNIX library..

    I'll try this method and get back to you.

    Like I said its a basis for a pong game, for which I have most of the code for. I need to make the walls and paddle..

    Any help on that question would be great too.


    Author Comment

    Hey brettmjohnson,

    Ive tried making a window using the examples.

    However all I get are errors..

    The examples given dont actually help.

    Could u provide any help.

    LVL 23

    Accepted Solution


    Author Comment

    I've already done the research and found those sites plus many more.

    They dont give any simple examples.

    I just need to draw a border, but they show how to resize, move, etc. And cutting up the code is hard as I've never delt with curses before.

    Thanks anyways.

    Expert Comment

    Pong on a unix console... I remember the days....  Do yo uactually have access to the Curses lirary function. Your previuos comment "However all I get are errors.." doesn't tell us if these are complile errors or runtime errors....  What version of Unix are you running under?  Send some source code examples of what you are doing.

    Author Comment

    I got it working using standout() - reverse video.

    Main tutorials I used were those provided by user 'brettmjohnson'.

    Plus other curses tutorials and man pages...


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
    This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now