搜索
首页后端开发C#.Net教程C语言库函数 (B类字母)

C语言库函数 (B类字母)

Dec 16, 2016 am 09:44 AM
c语言函数

函数名: bar 
功 能: 画一个二维条形图 
用 法: void far bar(int left, int top, int right, int bottom); 
程序例: 
#include  
#include  
#include  
#include int main(void) 

/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int midx, midy, i; /* initialize graphics and local variables */ 
initgraph(&gdriver, &gmode, ""); /* read result of initialization */ 
errorcode = graphresult(); 
if (errorcode != grOk) /* an error occurred */ 

PRintf("Graphics error: %s\n", grapherrormsg(errorcode)); 
printf("Press any key to halt:"); 
getch(); 
exit(1); /* terminate with an error code */ 
} midx = getmaxx() / 2; 
midy = getmaxy() / 2; /* loop through the fill patterns */ 
for (i=SOLID_FILL; i
/* set the fill style */ 
setfillstyle(i, getmaxcolor()); /* draw the bar */ 
bar(midx-50, midy-50, midx+50, 
midy+50); getch(); 
} /* clean up */ 
closegraph(); 
return 0; 

函数名: bar3d 
功 能: 画一个三维条形图 
用 法: void far bar3d(int left, int top, int right, int bottom, 
int depth, int topflag); 
程序例: #include  
#include  
#include  
#include int main(void) 

/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int midx, midy, i; /* initialize graphics, local variables */ 
initgraph(&gdriver, &gmode, ""); /* read result of initialization */ 
errorcode = graphresult(); 
if (errorcode != grOk) /* an error occurred */ 

printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
printf("Press any key to halt:"); 
getch(); 
exit(1); /* terminate with error code */ 
} midx = getmaxx() / 2; 
midy = getmaxy() / 2; /* loop through the fill patterns */ 
for (i=EMPTY_FILL; i
/* set the fill style */ 
setfillstyle(i, getmaxcolor()); /* draw the 3-d bar */ 
bar3d(midx-50, midy-50, midx+50, midy+50, 10, 1); getch(); 
} /* clean up */ 
closegraph(); 
return 0; 

函数名: bdos 
功 能: DOS系统调用 
用 法: int bdos(int dosfun, unsigned dosdx, unsigned dosal); 
程序例: #include  
#include /* Get current drive as 'A', 'B', ... */ 
char current_drive(void) 

char curdrive; /* Get current disk as 0, 1, ... */ 
curdrive = bdos(0x19, 0, 0); 
return('A' + curdrive); 
} int main(void) 

printf("The current drive is %c:\n", current_drive()); 
return 0; 

函数名: bdosptr 
功 能: DOS系统调用 
用 法: int bdosptr(int dosfun, void *argument, unsigned dosal); 
程序例: #include  

#include  
#include  
#include  
#include  
#include #define BUFLEN 80 int main(void) 

char buffer[BUFLEN]; 
int test; printf("Enter full pathname of a Directory\n"); 
gets(buffer); test = bdosptr(0x3B,buffer,0); 
if(test) 

printf("DOS error message: %d\n", errno); 
/* See errno.h for error listings */ 
exit (1); 
} getcwd(buffer, BUFLEN); 
printf("The current directory is: %s\n", buffer); return 0; 

函数名: bioscom 
功 能: 串行I/O通信 
用 法: int bioscom(int cmd, char abyte, int port); 
程序例: #include  
#include #define COM1 0 
#define DATA_READY 0x100 
#define TRUE 1 
#define FALSE 0 #define SETTINGS ( 0x80 0x02 0x00 0x00) int main(void) 

int in, out, status, DONE = FALSE; bioscom(0, SETTINGS, COM1); 
cprintf("... BIOSCOM [ESC] to exit ...\n"); 
while (!DONE) 

status = bioscom(3, 0, COM1); 
if (status & DATA_READY) 
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) 
putch(out); 
if (kbhit()) 

if ((in = getch()) == '\x1B') 
DONE = TRUE; 
bioscom(1, in, COM1); 


return 0; 

函数名: biosdisk 
功 能: 软硬盘I/O 
用 法: int biosdisk(int cmd, int drive, int head, int track, int sector 
int nsects, void *buffer); 
程序例: #include  
#include int main(void) 

int result; 
char buffer[512]; printf("Testing to see if drive a: is ready\n"); 
result = biosdisk(4,0,0,0,0,1,buffer); 
result &= 0x02; 
(result) ? (printf("Drive A: Ready\n")) : 
(printf("Drive A: Not Ready\n")); return 0; 

函数名: biosequip 
功 能: 检查设备 
用 法: int biosequip(void); 
程序例: #include  
#include int main(void) 

int result; 
char buffer[512]; printf("Testing to see if drive a: is ready\n"); 
result = biosdisk(4,0,0,0,0,1,buffer); 
result &= 0x02; 
(result) ? (printf("Drive A: Ready\n")) : 
(printf("Drive A: Not Ready\n")); return 0; 

函数名: bioskey 
功 能: 直接使用BIOS服务的键盘接口 
用 法: int bioskey(int cmd); 
程序例: #include  
#include  
#include #define RIGHT 0x01 
#define LEFT 0x02 
#define CTRL 0x04 
#define ALT 0x08 int main(void) 

int key, modifiers; /* function 1 returns 0 until a key is pressed */ 
while (bioskey(1) == 0); /* function 0 returns the key that is waiting */ 
key = bioskey(0); /* use function 2 to determine if shift keys were used */ 

modifiers = bioskey(2); 
if (modifiers) 

printf("["); 
if (modifiers & RIGHT) printf("RIGHT"); 
if (modifiers & LEFT) printf("LEFT"); 
if (modifiers & CTRL) printf("CTRL"); 
if (modifiers & ALT) printf("ALT"); 
printf("]"); 

/* print out the character read */ 
if (isalnum(key & 0xFF)) 
printf("'%c'\n", key); 
else 
printf("%#02x\n", key); 
return 0; 
} 函数名: biosmemory 
功 能: 返回存储块大小 
用 法:int biosmemory(void); 
程序例: #include  
#include int main(void) 

int memory_size; memory_size = biosmemory(); /* returns value up to 640K */ 
printf("RAM size = %dK\n",memory_size); 
return 0; 

函数名: biosprint 
功 能: 直接使用BIOS服务的打印机I/O 
用 法: int biosprint(int cmd, int byte, int port); 
程序例: #include  
#include  
#include int main(void) 

#define STATUS 2 /* printer status command */ 
#define PORTNUM 0 /* port number for LPT1 */ int status, abyte=0; printf("Please turn off your printer. Press any key to continue\n"); 
getch(); 
status = biosprint(STATUS, abyte, PORTNUM); 
if (status & 0x01) 
printf("Device time out.\n"); 
if (status & 0x08) 
printf("I/O error.\n"); if (status & 0x10) 
printf("Selected.\n"); 
if (status & 0x20) 
printf("Out of paper.\n"); if (status & 0x40) 
printf("Acknowledge.\n"); 
if (status & 0x80) 
printf("Not busy.\n"); return 0; 

函数名: biostime 
功 能: 读取或设置BIOS时间 
用 法: long biostime(int cmd, long newtime); 
程序例: #include  
#include  
#include  
#include int main(void) 

long bios_time; clrscr(); 
cprintf("The number of clock ticks since midnight is:\r\n"); 
cprintf("The number of seconds since midnight is:\r\n"); 
cprintf("The number of minutes since midnight is:\r\n"); 
cprintf("The number of hours since midnight is:\r\n"); 
cprintf("\r\nPress any key to quit:"); 
while(!kbhit()) 

bios_time = biostime(0, 0L); gotoxy(50, 1); 
cprintf("%lu", bios_time); gotoxy(50, 2); 
cprintf("%.4f", bios_time / CLK_TCK); gotoxy(50, 3); 
cprintf("%.4f", bios_time / CLK_TCK / 60); gotoxy(50, 4); 
cprintf("%.4f", bios_time / CLK_TCK / 3600); 

return 0; 

函数名: brk 
功 能: 改变数据段空间分配 
用 法: int brk(void *endds); 
程序例: #include  
#include int main(void) 

char *ptr; printf("Changing allocation with brk()\n"); 
ptr = malloc(1); 
printf("Before brk() call: %lu bytes free\n", coreleft()); 

brk(ptr+1000); 
printf(" After brk() call: %lu bytes free\n", coreleft()); 
return 0; 

函数名: bsearch 
功 能: 二分法搜索 
用 法: void *bsearch(const void *key, const void *base, size_t *nelem, 
size_t width, int(*fcmp)(const void *, const *)); 
程序例: #include  
#include #define NELEMS(arr) (sizeof(arr) / sizeof(arr[0])) int numarray[] = {123, 145, 512, 627, 800, 933}; int numeric (const int *p1, const int *p2) 

return(*p1 - *p2); 
} int lookup(int key) 

int *itemptr; /* The cast of (int(*)(const void *,const void*)) 
is needed to avoid a type mismatch error at 
compile time */ 
itemptr = bsearch (&key, numarray, NELEMS(numarray), 
sizeof(int), (int(*)(const void *,const void *))numeric); 
return (itemptr != NULL); 
} int main(void) 

if (lookup(512)) 
printf("512 is in the table.\n"); 
else 
printf("512 isn't in the table.\n"); return 0; 

以上就是C语言库函数 (B类字母)的内容,更多相关文章请关注PHP中文网(www.php.cn)!


声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
C#.NET与未来:适应新技术C#.NET与未来:适应新技术Apr 14, 2025 am 12:06 AM

C#和.NET通过不断的更新和优化,适应了新兴技术的需求。1)C#9.0和.NET5引入了记录类型和性能优化。2).NETCore增强了云原生和容器化支持。3)ASP.NETCore与现代Web技术集成。4)ML.NET支持机器学习和人工智能。5)异步编程和最佳实践提升了性能。

c#.net适合您吗?评估其适用性c#.net适合您吗?评估其适用性Apr 13, 2025 am 12:03 AM

c#.netissutableforenterprise-levelapplications withemofrosoftecosystemdueToItsStrongTyping,richlibraries,androbustperraries,androbustperformance.however,itmaynotbeidealfoross-platement forment forment forment forvepentment offependment dovelopment toveloperment toveloperment whenrawspeedsportor whenrawspeedseedpolitical politionalitable,

.NET中的C#代码:探索编程过程.NET中的C#代码:探索编程过程Apr 12, 2025 am 12:02 AM

C#在.NET中的编程过程包括以下步骤:1)编写C#代码,2)编译为中间语言(IL),3)由.NET运行时(CLR)执行。C#在.NET中的优势在于其现代化语法、强大的类型系统和与.NET框架的紧密集成,适用于从桌面应用到Web服务的各种开发场景。

C#.NET:探索核心概念和编程基础知识C#.NET:探索核心概念和编程基础知识Apr 10, 2025 am 09:32 AM

C#是一种现代、面向对象的编程语言,由微软开发并作为.NET框架的一部分。1.C#支持面向对象编程(OOP),包括封装、继承和多态。2.C#中的异步编程通过async和await关键字实现,提高应用的响应性。3.使用LINQ可以简洁地处理数据集合。4.常见错误包括空引用异常和索引超出范围异常,调试技巧包括使用调试器和异常处理。5.性能优化包括使用StringBuilder和避免不必要的装箱和拆箱。

测试C#.NET应用程序:单元,集成和端到端测试测试C#.NET应用程序:单元,集成和端到端测试Apr 09, 2025 am 12:04 AM

C#.NET应用的测试策略包括单元测试、集成测试和端到端测试。1.单元测试确保代码的最小单元独立工作,使用MSTest、NUnit或xUnit框架。2.集成测试验证多个单元组合的功能,常用模拟数据和外部服务。3.端到端测试模拟用户完整操作流程,通常使用Selenium进行自动化测试。

高级C#.NET教程:ACE您的下一次高级开发人员面试高级C#.NET教程:ACE您的下一次高级开发人员面试Apr 08, 2025 am 12:06 AM

C#高级开发者面试需要掌握异步编程、LINQ、.NET框架内部工作原理等核心知识。1.异步编程通过async和await简化操作,提升应用响应性。2.LINQ以SQL风格操作数据,需注意性能。3..NET框架的CLR管理内存,垃圾回收需谨慎使用。

C#.NET面试问题和答案:提高您的专业知识C#.NET面试问题和答案:提高您的专业知识Apr 07, 2025 am 12:01 AM

C#.NET面试问题和答案包括基础知识、核心概念和高级用法。1)基础知识:C#是微软开发的面向对象语言,主要用于.NET框架。2)核心概念:委托和事件允许动态绑定方法,LINQ提供强大查询功能。3)高级用法:异步编程提高响应性,表达式树用于动态代码构建。

使用C#.NET建筑微服务:建筑师实用指南使用C#.NET建筑微服务:建筑师实用指南Apr 06, 2025 am 12:08 AM

C#.NET是构建微服务的热门选择,因为其生态系统强大且支持丰富。1)使用ASP.NETCore创建RESTfulAPI,处理订单创建和查询。2)利用gRPC实现微服务间的高效通信,定义和实现订单服务。3)通过Docker容器化微服务,简化部署和管理。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器