output an array to curses, or to another window?

This is a discussion on output an array to curses, or to another window? within the C++ Programming forums, part of the General Programming Boards category; Hello all. My question is that I have two arrays (one a string with names, another an int with scores) ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 02: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, 09:01 PM

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