易截截图软件、单文件、免安装、纯绿色、仅160KB

C/C++——小编谈C语言函数那些事(26)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.   sopen函数
sopen函数的功能是打开一共享文件,其用法为:int sopen(char *pathname, int access, int shflag, int permiss);程序实例如下:
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <process.h>
#include <share.h>
#include <stdio.h>
int main(void)
{
   int handle;
   int status;
   handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD);
   if (!handle)
   {
      printf("sopen failed\n");
      exit(1);
   }
   status = access("c:\\autoexec.bat", 6);
   if (status == 0)
      printf("read/write access allowed\n");
   else
      printf("read/write access not allowed\n");
   close(handle);
   return 0;
}
 2.  spawnl函数
spawnl函数的功能是创建并运行子程序,其用法为int spawnl(int mode, char *pathname, char *arg0,arg1, ... argn, NULL);程序实例代码如下:
#include <process.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   int result;
   clrscr();
   result = spawnl(P_WAIT, "tcc.exe", NULL);
   if (result == -1)
   {
      perror("Error from spawnl");
      exit(1);
   }
   return 0;
}
3.  srand函数
srand函数的功能是初始化随机数发生器, 其用法为:void srand(unsigned seed);程序实例代码如下:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
   int i;
   time_t t;
   srand((unsigned) time(&t));
   printf("Ten random numbers from 0 to 99\n\n");
   fo


相关文档:

C/C++——小编谈C语言函数那些事(21)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.     setfillpatterne函数
setfillpatterne函数的功能是选择用户定义的填充模式,其用法为:void far setfillpattern(char far *upattern, int ......

羊绒被誉为“软金子”也成B二C的拓荒者

羊绒被是以山羊绒为原材料针织物而成的床上用品,依据纱线种类分成粗纺织品和精纺针织物两种,依据原材料比值可以分成纯羊绒及羊绒混纺两种经加工而成的生活用品,供暖性好,盖着舒坦,尽显高档咀嚼。 本文来源:甘肃庆阳腾达商贸 ......

linux c++连接mysql示例

 
 编译和连接程序
  MySQL中有一个特殊的脚本,叫做mysql_config. 它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.你需要使用下面两个选项.
  1. --libs 选项 - 连接MySQL客户端函数库所需要的库和选项.
  $ mysql_config --libs
  2. --cflags 选项 - 使用必要的include文件的选项等等.
......

C/C++——小编谈C语言函数那些事(22)

C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
 
1.    setmem函数
setmem函数的功能是存值到存储区,其用法为:void setmem(void *addr, int len, char value);程序实例如下:
#include <stdio.h& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号