Thread: output an array to curses, or to another window?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    16

    output an array to curses, or to another window?

    Hello all. My question is that I have two arrays (one a string with names, another an int with scores) that read from a file, sort, swap, and output the arrays to cout. Now that works all fine and dandy if i cout it. Now my question is that im using it for a game in which im using curses, so im playing the actual game in curses. Is there anyway to output those arrays to the curses window? If not is it possible that after the game is over, i could make the program open a window and display them there? Basically im looking for anyway I can output these two arrays in a window. Heres my code for the cout part that works fine. Thanks for any help!

    Code:
    void printArray(string names[SIZE], int scores[SIZE], int len){
    	for(int i=0;i<len;i++){
    		cout << names[i] << " " << scores[i] << endl;
    	}
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Build everything up in a string stream.

    Then use the c_str() method of the string stream to get something you can pass to an ncurses text output function.
    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.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    16
    Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  2. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM