• Standard C Library 思维火花 博客频道 CSDN.NET


    Standard C Library - 思维火花 - 博客频道 - CSDN.NET

    The return value of signal() is the address of the previously defined function for this signal, or SIG_ERR is there is an

    error.
    srand
    Syntax:

      #include <stdlib.h>
      void srand( unsigned seed );

    The function srand() is used to seed the random sequence generated by rand(). For any given seed, rand() will generate a

    specific "random" sequence over and over again.

        srand( time(NULL) );
        for( i = 0; i < 10; i++ )
          printf( "Random number #%d: %d/n", i, rand() );

    Related topics:
    rand(), time().
    system
    Syntax:

      #include <stdlib.h>
      int system( const char *command );

    The system() function runs the given command as a system call. The return value is usually zero if the command executed

    without errors. If command is NULL, system() will test to see if there is a command interpreter available. Non-zero will be

    returned if there is a command interpreter available, zero if not.
    Related topics:
    exit(),
    va_arg
    Syntax:

      #include <stdarg.h>
      type va_arg( va_list argptr, type );
      void va_end( va_list argptr );
      void va_start( va_list argptr, last_parm );

    The va_arg() macros are used to pass a variable number of arguments to a function.

       1. First, you must have a call to va_start() passing a valid va_list and the mandatory first argument of the function.

    This first argument describes the number of parameters being passed.
       2. Next, you call va_arg() passing the va_list and the type of the argument to be returned. The return value of va_arg()

    is the current parameter.
       3. Repeat calls to va_arg() for however many arguments you have.
       4. Finally, a call to va_end() passing the va_list is necessary for proper cleanup.

    For example:

        int sum( int, ... );
        int main( void ) {
       
          int answer = sum( 4, 4, 3, 2, 1 );
          printf( "The answer is %d/n", answer );
       
          return( 0 );
        }
       
        int sum( int num, ... ) {
          int answer = 0;
          va_list argptr;
       
          va_start( argptr, num );
          for( ; num > 0; num-- )
            answer += va_arg( argptr, int );
       
          va_end( argptr );
          return( answer );
        }

    This code displays 10, which is 4+3+2+1.
    =============================================

  • 相关阅读:
    小白简单留言板(2)-将表单信息输入数据库
    小白简单留言板(1)-页面设置等
    HTMLCSS学习
    golang函数调用计时
    iOS中堆和栈的区别
    UIButton的继承链
    TCP三次握手
    iOS 控制任务执行顺序
    将NSNumber转成字符串,为什么.0丢失
    HTTP状态码
  • 原文地址:https://www.cnblogs.com/lexus/p/2582045.html
Copyright © 2020-2023  润新知