There is. I am going to assume you are using C, not C++, and you are using the console. here it goes. this is probably going to be more complicated and tedious than the \n and \t, but its alot cooler.::
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#define SCREEN_WIDTH 79 //this is the default prompt window width( 80
//characters, 0 counts
#define SCREEN_LENGTH 24 //this is the default prompt window length, 25
void DrawColorString(char *szText, int X, int Y, WORD COLORS); //parameters:
//(string you want,x coordinate,y coordinate, the color).
//the colors are:
//BACKGROUND_RED,BACKGROUND_BLUE,BACKGROUND_GREEN,
//BACKGROUND_INTENSITY(makes the background color lighter),
//FOREGROUND_RED,FOREGROUND_BLUE,FOREGROUND_GREEN, and
//FOREGROUND_INTENSITY(makes the foreground color lighter)
void DrawColorString(char *szText, int X, int Y, WORD COLORS)
{
COORD screenPos={X, Y};
WORD *colorBuf=NULL;
DWORD dwResult=0;
HANDLE OutputH;
int length=0;
int i=0;
if(szText == NULL)
return;
OutputH = GetStdHandle(STD_OUTPUT_HANDLE);
length = strlen(szText);
colorBuf = (WORD*)malloc(sizeof(WORD) * length);
for (i=0; i < length; i++)
{
colorBuf[i] = COLORS;
}
WriteConsoleOutputAttribute(OutputH, colorBuf, length, screenPos, &dwResult);
WriteConsoleOutputCharacter(OutputH, szText, length, screenPos, &dwResult);
free(colorBuf);
colorBuf = NULL;
} //if you understand all of that, you do, and if you dont, you dont. lol
int main() {
DrawColorString("Word here!", 7, 2, FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
getchar();
return 0;
}
Noorez Kassam <coo...@ho...> wrote:
I want to output text in a program to the center of the command prompt
window. Is there a function that can help we with it so that I don't have to
use the '\n' and '\t' characters?
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN Premium
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
---------------------------------
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger |