tell - 取得檔案指標當前位置
long tell(int handle);
// 範例:開啟檔案寫入後查詢指標位置
int handle = open("TEST.$$$", O_CREAT | O_TEXT | O_APPEND);
write(handle, "Hello world", 11);
printf("檔案指標位於位元組 %ld\n", tell(handle));
close(handle);
textattr / textbackground / textcolor - 文字模式屬性設定
void textattr(int attribute); // 設定前景/背景組合屬性
void textbackground(int color); // 設定背景色
void textcolor(int color); // 設定前景色
// 色碼:0=黑 1=藍 2=綠 3=青 4=紅 5=洋紅 6=棕 7=淺灰 8=深灰 9=亮藍 ...
textheight / textwidth - 文字尺寸查詢
int textheight(char *text); // 回傳字串像素高度
int textwidth(char *text); // 回傳字串像素寬度
vfprintf / vfscanf / vprintf / vscanf / vsprintf / vsscanf - 變參格式化 I/O
int vfprintf(FILE *stream, const char *format, va_list arg);
int vfscanf(FILE *stream, const char *format, va_list arg);
int vprintf(const char *format, va_list arg);
int vscanf(const char *format, va_list arg);
int vsprintf(char *buffer, const char *format, va_list arg);
int vsscanf(const char *buffer, const char *format, va_list arg);
// 配合 va_start/va_end 實作自訂格式化函數
wherex / wherey - 文字視窗游標位置
int wherex(void); // 水平位置 (1-based)
int wherey(void); // 垂直位置
window - 定義文字模式作用視窗
void window(int left, int top, int right, int bottom);
// 後續文字輸出限制於此矩形區域
write - 低層檔案寫入
int write(int handle, const void *buf, unsigned nbyte);
// 範例:建立檔案並寫入字串
int handle = open("TEST.$$$", O_WRONLY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
write(handle, "Hello, world!", 13);
close(handle);
textmode - 設定螢幕文字模式
void textmode(int mode);
// 模式常數:BW40, C40, BW80, C80, MONO 等
使用提醒
- 上述多為 Borland/Turbo C 專用(
conio.h, graphics.h),現代編譯器(GCC/MSVC/Clang)不支援。
- 跨平台專案請使用 ANSI C 標準庫(
printf/scanf、fread/fwrite、ncurses 等)。
- 圖形函數需連結
graphics.lib 並置於 BGI 驅動程式目錄。