please tell me: why does it loop forever?

I want to draw a row consits of 10 * symboys. but this source code lead to loop foever. and i don't know why?
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
28
29
30
31
32
33
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include "conio.h"
#include <windows.h>


using namespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void gotoXY(int x, int y); 
int main(int argc, char *argv[])
{
    int i=5,j=10;
             for (j=10;j++;j<=20) 
         {
           gotoXY(i,j);
           cout<<" * ";
           
          }
          
        system ("pause");
        return 0;        
}


void gotoXY(int x, int y) 
{ 
CursorPosition.X = x; // Locates column
CursorPosition.Y = y; // Locates Row
SetConsoleCursorPosition(console,CursorPosition); // Sets position for next thing to be printed 
}

Last edited on
for (j=10;j++;j<=20)

I think you mean for(j=10; j<=20; j++)
Last edited on
thanks so much. it's now ok.:D
Topic archived. No new replies allowed.