g++ ncurses help

Code junkies hangout here

Moderators: ChriThor, LXF moderators

g++ ncurses help

Postby fpga » Tue Sep 12, 2006 8:19 am

Code: Select all
#include <curses.h>
run this code as is, noting that all 'sets' print out correctly with their right edges aligned at x=15.

Then change PROBLEM's value to 1 and re-run.

Why does changing b2's 'capacity' to 9 cause it to start printing out
at a position other than x=15?

If I make b2's capacity 8 or 10 I don't get a problem.
Any help in explaining the right shift and how to stop it would be most
Best regards

#define PROBLEM 0   

class SetupPad {
      WINDOW * ptr; //ie pPad

      ~SetupPad() { delwin(ptr); endwin(); }
      void linesCols();


void SetupPad::linesCols()
   ptr = newpad(LINES-1,COLS-1);
class Set
   int x,y,cap;
   Set(int nx,int ny, int ncap) : x(nx),y(ny),cap(ncap) {}
void drawQ(Set * pS,WINDOW * pWin)
   int x=pS->x;
   int y=pS->y;
   char sym = '.';
   for (int j=0;j<pS->cap;j++)
      mvwaddch(pWin, y, x--, sym);

void updtScn(SetupPad * pPad)

int main()
   SetupPad pad;
   Set b1(15,1,13);
   Set m1(15,2,10);
   Set m2(15,3,10);

   Set b2(15,4,9);
   Set b2(15,4,10);   //works with 8 too!
   for (int i=0;i<1000000000;i++); //delay so you can see it
   return 0;

Posts: 5
Joined: Fri Aug 18, 2006 11:19 am

Return to Programming

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest