A ncurses problem

now that my problem is i want to print a shape like below but all my coding is invain coz its not hapenning so can any one correct my coding

the shape i want to print is

*
**
***
****
*****

starting coordinates are (5,20)

#include<ncurses.h>

void printshape(int row, int col);
void eraseshape(int row, int col);

int main()
{
initscr();
printshape(5,20);
getch();
endwin();
}


void printshape(int row,int col)
{
for(int x=row;x<10;x++)
{
for(int y=col;y<25;y++)
{
move(x,y);
printw("*");
}
}
}

void eraseshape(int row,int col)
{
for(int i=row;i<=row+col;i++)
{
for(int j=col;j<=row+col;j++)
{
move(i,j);
printw("*");
}
}
}


|
I think it's move(y, x) and not move(x, y)
There are a few other 'gotcha's in NCurses for those brain-damaged by conio.h (as I once was)... It is a good idea to have some really good documentation handy.
http://www.delorie.com/gnu/docs/ncurses/index.html
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
http://orgs.man.ac.uk/documentation/gnu/ncurses/

Hope this helps.

Oh, before I forget, a good idea is to init and finalize curses using an object:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
struct NCurses
  {
  NCurses()
    {
    initscr();
    raw();
    (void)noecho();
    nonl();
    intrflush( stdscr, FALSE );
    (void)keypad( stdscr, TRUE );
    //etc
    }
  ~NCurses()
    {
    endwin();
    }
  };

int main()
  {
  NCurses ncurses;

  printshape( 5, 20 );
  getch();

  return 0;
  }
Topic archived. No new replies allowed.