找回密码

碧海潮声大学生网

楼主: 墙角野猫
打印 上一主题 下一主题

c语言函数大全

[复制链接]
271#
 楼主| 发表于 2006-7-13 01:10 | 只看该作者
函数名: signal
功 能: 设置某一信号的对应动作
用 法: int signal(int sig, sigfun fname);
程序例:
/* This example installs a signal handler routine for SIGFPE,
catches an integer overflow condition, makes an adjustment
to AX register, and returns. This example program MAY cause
your computer to crash, and will produce runtime errors
depending on which memory model is used.
*/
#pragma inline
#include
#include
void Catcher(int sig, int type, int *reglist)
{
printf("Caught it!
");
*(reglist + 8) = 3; /* make return AX = 3 */
}
int main(void)
{
signal(SIGFPE, Catcher);
asm mov ax,07FFFH /* AX = 32767 */
asm inc ax /* cause overflow */
asm into /* activate handler */
/* The handler set AX to 3 on return. If that hadn't happened,
there would have been another exception when the next 'into'
was executed after the 'dec' instruction. */
asm dec ax /* no overflow now */
asm into /* doesn't activate */
return 0;
}
272#
 楼主| 发表于 2006-7-13 01:11 | 只看该作者
函数名: sin
功 能: 正弦函数
用 法: double sin(double x);
程序例:
#include
#include
int main(void)
{
double result, x = 0.5;
result = sin(x);
printf("The sin() of %lf is %lf
", x, result);
return 0;
}
273#
 楼主| 发表于 2006-7-13 01:11 | 只看该作者
函数名: sinh
功 能: 双曲正弦函数
用 法: double sinh(double x);
程序例:
#include
#include
int main(void)
{
double result, x = 0.5;
result = sinh(x);
printf("The hyperbolic sin() of %lf is %lf
", x, result);
return 0;
}
274#
 楼主| 发表于 2006-7-13 01:11 | 只看该作者
函数名: sleep
功 能: 执行挂起一段时间
用 法: unsigned sleep(unsigned seconds);
程序例:
#include
#include
int main(void)
{
int i;
for (i=1; i<5; i++)
{
printf("Sleeping for %d seconds
", i);
sleep(i);
}
return 0;
}
275#
 楼主| 发表于 2006-7-13 01:12 | 只看该作者
函数名: sopen
功 能: 打开一共享文件
用 法: int sopen(char *pathname, int access, int shflag, int permiss);
程序例:
#include
#include
#include
#include
#include
#include
int main(void)
{
int handle;
int status;
handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD);
if (!handle)
{
printf("sopen failed
");
exit(1);
}
status = access("c:\\autoexec.bat", 6);
if (status == 0)
printf("read/write access allowed
");
else
printf("read/write access not allowed
");
close(handle);
return 0;
}
276#
 楼主| 发表于 2006-7-13 01:12 | 只看该作者
函数名: sound
功 能: 以指定频率打开PC扬声器
用 法: void sound(unsigned frequency);
程序例:
/* Emits a 7-Hz tone for 10 seconds.
Your PC may not be able to emit a 7-Hz tone. */
#include
int main(void)
{
sound(7);
delay(10000);
nosound();
return 0;
}
277#
 楼主| 发表于 2006-7-13 01:12 | 只看该作者
函数名: spawnl
功 能: 创建并运行子程序
用 法: int spawnl(int mode, char *pathname, char *arg0,
arg1, ... argn, NULL);
程序例:
#include
#include
#include
int main(void)
{
int result;
clrscr();
result = spawnl(P_WAIT, "tcc.exe", NULL);
if (result == -1)
{
perror("Error from spawnl");
exit(1);
}
return 0;
}
278#
 楼主| 发表于 2006-7-13 01:12 | 只看该作者
函数名: spawnle
功 能: 创建并运行子程序
用 法: int spawnle(int mode, char *pathname, char *arg0,
arg1,..., argn, NULL);
程序例:
/* spawnle() example */
#include
#include
#include
int main(void)
{
int result;
clrscr();
result = spawnle(P_WAIT, "tcc.exe", NULL, NULL);
if (result == -1)
{
perror("Error from spawnle");
exit(1);
}
return 0;
}
279#
 楼主| 发表于 2006-7-13 01:13 | 只看该作者
函数名: sprintf
功 能: 送格式化输出到字符串中
用 法: int sprintf(char *string, char *farmat [,argument,...]);
程序例:
#include
#include
int main(void)
{
char buffer[80];
sprintf(buffer, "An approximation of Pi is %f
", M_PI);
puts(buffer);
return 0;
}
280#
 楼主| 发表于 2006-7-13 01:13 | 只看该作者
函数名: sqrt
功 能: 计算平方根
用 法: double sqrt(double x);
程序例:
#include
#include
int main(void)
{
double x = 4.0, result;
result = sqrt(x);
printf("The square root of %lf is %lf
", x, result);
return 0;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋| 碧海潮声大学生网  

Copyright © 2001-2013 Comsenz Inc.   All Rights Reserved.

Powered by Discuz! X3.2( 浙ICP备11026473号 )

快速回复 返回顶部 返回列表