2011-04-04 98 views

回答

0

发现了.NET

#include <windows.h> 
#include <stdio.h> 

void Locate (int row, int col) 
{ if (row < 0 || row > 24) return; 
    if (col < 0 || col > 79) return; 
    COORD c = { (SHORT)col, (SHORT)row }; 
    SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), c); } 

void main () 
{ int row; 
    int col; 
    printf ("Row (0-24): "); scanf ("%d", &row); 
    printf ("Col (0-79): "); scanf ("%d", &col); 
    Locate (row, col); 
    printf ("This text is starting at row %d, column %d\n", row, col); } 
2

假设你正在谈论的输出位置,你可以在两个层次进行控制。

在最高级别上,您可以使用控制字符,例如回车符,换行符和换行符。查看离您最近的ASCII表格。

在较低级别,您可以使用Windows API控制台功能。

这些函数又分为两个级别,根据您想要控制的内容(例如对Ctrl C的响应),您可能需要将其细化到最低级别。

更便携的选择是使用一些便携式“终端”库,如ncurses。

Cheers & hth。,

相关问题