w_strcen.c

来自「[随书类]Dos6.0源代码」· C语言 代码 · 共 31 行

C
31
字号
/***************************************************************************/
/*																									*/
/*	W_STRCEN.C																					*/
/*                                                                         */
/*		Copyright (c) 1991 - Microsoft Corp.											*/
/*		All rights reserved.																	*/
/*		Microsoft Confidential																*/
/*                                                                         */
/* Returns the display column which cause the string passed as an argument */
/* to be displayed centered on the screen. 										   */
/*                                                                         */
/* int CenterStr( char *szString )														*/
/* 																								*/
/* ARGUMENTS:	szString - pointer to a string                              */
/* RETURNS: 	int column number which causes the string to be centered		*/
/*																									*/
/* johnhe - 03/15/89																			*/
/***************************************************************************/

#include		<string.h>
#include		<bios_io.h>

int CenterStr( char *szString )
{
	unsigned 					cch;
	extern unsigned char 	ScreenWidth;

   cch = strlen( szString );
	return( (int)(((VideoGetWidth() - cch) / 2) + (cch & 1 ? 1 : 0)) );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?