give me an example of gotoxy for loop program in c++
#include <iostream>
#include <cstdio>
#include <windows.h>
using namespace std;
void gotoxy(int x,int y)//Define a gotoxy yourself and jump the cursor to the x column and y row
{
COORD c; //Define a cursor class
c.X = x-1; //Set the position of the cursor
c.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); //Call WindowsAPI to set the cursor position
}
int main(){
for(int i=0;i<10;i++){
gotoxy(1,i*5+10);
cout << "Number "<<(i+1);
}
cin.get();
return 0;
}
Comments
Leave a comment