2011-04-04 31 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。,

相關問題