How to move this triangle?

#include<iostream>
#include<ncurses.h>
//#include<iostream>
using namespace std;
void triangle();
int main()
{
int ch;
int x;
x=20;
initscr();
keypad(stdscr,TRUE);
noecho();

move(5,x);

triangle();
ch =getch();
while(ch !='q')
{
if(ch==KEY_LEFT)
x=x-1;
else if(ch==KEY_RIGHT)
x=x+1;

move(5,x);
triangle();
ch=getch();
}
endwin();
return 0;
}

void triangle()
{
for(int i=0;i<4;i++)
{
for(int j=0;j<i;j++)
cout<<"*";
cout<<endl;
}
}
Topic archived. No new replies allowed.