数模论坛

 找回密码
 注-册-帐-号
搜索
热搜: 活动 交友 discuz

C语言的函数!

  [复制链接]
 楼主| 发表于 2004-5-10 16:42:34 | 显示全部楼层
<>函数名: 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 &lt;stdio.h&gt;
#include &lt;signal.h&gt; <P>void Catcher(int sig, int type, int *reglist)
{
   printf("Caught it!\n");
   *(reglist + 8) = 3;             /* make return AX = 3 */
} <P>int main(void)
{
   signal(SIGFPE, Catcher);
   asm     mov     ax,07FFFH       /* AX = 32767 */
   asm     inc     ax              /* cause overflow */
   asm     into                    /* activate handler */ <P>   /* 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;
}
  
</P>
 楼主| 发表于 2004-5-10 16:42:44 | 显示全部楼层
<>函数名: sin
功  能: 正弦函数
用  法: double sin(double x);
程序例: <>#include &lt;stdio.h&gt;
#include &lt;math.h&gt; <>int main(void)
{
   double result, x = 0.5; <P>   result = sin(x);
   printf("The sin() of %lf is %lf\n", x, result);
   return 0;
}
</P>
 楼主| 发表于 2004-5-10 16:43:03 | 显示全部楼层
<>函数名: sinh
功  能: 双曲正弦函数
用  法: double sinh(double x);
程序例: <>#include &lt;stdio.h&gt;
#include &lt;math.h&gt; <>int main(void)
{
   double result, x = 0.5; <P>   result = sinh(x);
   printf("The hyperbolic sin() of %lf is %lf\n", x, result);
   return 0;
}
</P>
 楼主| 发表于 2004-5-10 16:43:13 | 显示全部楼层
<>函数名: sleep
功  能: 执行挂起一段时间
用  法: unsigned sleep(unsigned seconds);
程序例: <>#include &lt;dos.h&gt;
#include &lt;stdio.h&gt; <>int main(void)
{
   int i; <P>   for (i=1; i&lt;5; i++)
   {
      printf("Sleeping for %d seconds\n", i);
      sleep(i);
   }
   return 0;
}
  
</P>
 楼主| 发表于 2004-5-10 16:43:23 | 显示全部楼层
<>函数名: sopen
功  能: 打开一共享文件
用  法: int sopen(char *pathname, int access, int shflag, int permiss);
程序例: <>#include &lt;io.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;sys\stat.h&gt;
#include &lt;process.h&gt;
#include &lt;share.h&gt;
#include &lt;stdio.h&gt; <>int main(void)
{
   int handle;
   int status; <P>   handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD); <P>   if (!handle)
   {
      printf("sopen failed\n");
      exit(1);
   } <P>   status = access("c:\\autoexec.bat", 6);
   if (status == 0)
      printf("read/write access allowed\n");
   else
      printf("read/write access not allowed\n"); <P>   close(handle);
   return 0;
}
  
  
</P>
 楼主| 发表于 2004-5-10 16:43:33 | 显示全部楼层
<>函数名: 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 &lt;dos.h&gt; <>int main(void)
{
   sound(7);
   delay(10000);
   nosound();
   return 0;
}
</P>
 楼主| 发表于 2004-5-10 16:43:42 | 显示全部楼层
<>函数名: spawnl
功  能: 创建并运行子程序
用  法: int spawnl(int mode, char *pathname, char *arg0,
     arg1, ... argn, NULL);
程序例: <>#include &lt;process.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt; <>int main(void)
{
   int result; <P>   clrscr();
   result = spawnl(P_WAIT, "tcc.exe", NULL);
   if (result == -1)
   {
      perror("Error from spawnl");
      exit(1);
   }
   return 0;
}
  
</P>
 楼主| 发表于 2004-5-10 16:43:50 | 显示全部楼层
<>函数名: spawnle
功  能: 创建并运行子程序
用  法: int spawnle(int mode, char *pathname, char *arg0,
      arg1,..., argn, NULL);
程序例: <>/* spawnle() example */ <>#include &lt;process.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt; <P>int main(void)
{
   int result; <P>   clrscr();
   result = spawnle(P_WAIT, "tcc.exe", NULL, NULL);
   if (result == -1)
   {
      perror("Error from spawnle");
      exit(1);
   }
   return 0;
}
  
</P>
 楼主| 发表于 2004-5-10 16:44:01 | 显示全部楼层
<>函数名: sprintf
功  能: 送格式化输出到字符串中
用  法: int sprintf(char *string, char *farmat [,argument,...]);
程序例: <>#include &lt;stdio.h&gt;
#include &lt;math.h&gt; <>int main(void)
{
   char buffer[80]; <P>   sprintf(buffer, "An approximation of Pi is %f\n", M_PI);
   puts(buffer);
   return 0;
}
  
</P>
 楼主| 发表于 2004-5-10 16:44:14 | 显示全部楼层
<>函数名: sqrt
功  能: 计算平方根
用  法: double sqrt(double x);
程序例: <>#include &lt;math.h&gt;
#include &lt;stdio.h&gt; <> int main(void)
{
    double x = 4.0, result; <P>    result = sqrt(x);
    printf("The square root of %lf is %lf\n", x, result);
    return 0;
}
</P>
您需要登录后才可以回帖 登录 | 注-册-帐-号

本版积分规则

小黑屋|手机版|Archiver|数学建模网 ( 湘ICP备11011602号 )

GMT+8, 2024-11-27 08:32 , Processed in 0.055548 second(s), 12 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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