文档介绍:函数名: 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;
}
函数名: 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, "", NULL);
if (result == -1)
{
perror("Error from spawnl");
exit(1);
}
return 0;
}
函数名: 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, "", NULL, NULL);
if (result == -1)
{
perror("Error from spawnle");
exit(1);
}
return 0;
}
函数名: sprintf
功能: 送格式化输出到字符串中
用法: int sprintf(char *string, char *farmat [,argument,...]);
程序例:
#include <>
#include <>
int main(void)
{
char buffer[80];
sprintf(buffer, "An approximation of Pi is %f\n", M_PI);
puts(buffer);
return 0;
}
函数名: sqrt
功能: 计算平方根
用法: double sqrt(double x);
程序例:
#include <>
#include <>
int main(void)
{
double x = , result;
result = sqrt(x);
printf("The square root of %lf is %lf\n", x, result);
return 0;
}
函数名: srand
功能: 初始化随机数发生器
用法: void srand(unsigned seed);
程序例:
#include <>
#include <>
#include <>
int main(void)
{
int i;
time_t t;
srand((unsigned) time(&t));
printf("Ten random numbers from 0 to 99\n\n");
for(i=0; i<10; i++)
printf("%d\n", rand() % 100);
return 0;
}
函数名: sscanf
功能: 执行从字符串中的格式化输入
用法: int sscanf(char *string, char *format[,argument,...]);
程序例:
#include <>
#include <>
int main(void)
{
char label[20];
char name[20];
int entries = 0;
int loop, age;
double salary;
struc