This did not compile..error messages are below.....//

#include<ncurses.h>
int printtriangle(int i, int c ,int j);
int main()
{
int c, i, j;
c = 14;
initscr();
printtriangle(i,c,j);
getch();
endwin();
return 0;
}
int printtriangle(int i, int c ,int j)
for(int i=1;i<15;i++)
{
for(int j=(c-i);j<i+1;j++)
{
move(i,j);
printw("*");
}
}
*/ Error messages
triangle.cpp:14:1: error: expected initializer before ‘for’
triangle.cpp:14:13: error: ‘i’ does not name a type
triangle.cpp:14:18: error: ‘i’ does not name a type */
Last edited on
1
2
int printtriangle(int i, int c ,int j)
for(int i=1;i<15;i++)
Add { after first line and } after your function ends

And I would like you to post exactly where are the lines where errors are.
Last edited on
Sorry.....see below the programme....//
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<ncurses.h>
int printtriangle(int i, int c ,int j);
int main()
{
int c, i, j;
c = 14;
initscr();
printtriangle(i,c,j);
getch();
endwin();
return 0;
}
int printtriangle(int i, int c ,int j)
//the error is here, this is the beginning of the function printtriangle()
//but where is the body braces { } before starting the "for"
for(int i=1;i<15;i++)
{
for(int j=(c-i);j<i+1;j++)
{
move(i,j);
printw("*");
}
}
Thank you very much sir.....//
Topic archived. No new replies allowed.