Code:
#include <windows.h>
#include <string>
#ifndef _CENTRE_H
#define _CENTRE_H
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void center(char txt[60], int height)
{
int number, spaces;
number = std::strlen(txt);
spaces = 40 - number/2;
gotoxy (spaces,height);
cout << txt << endl;
}
#endif
Stick that in a header file, call it "centre.h" or "center.h" if you're a yank. Then, place it in the directory of the program you're attemping to compile and #include "centre.h"