设为首页 加入收藏

TOP

c语言函数天天见
2015-01-22 21:37:34 来源: 作者: 【 】 浏览:84
Tags:语言 函数 天天

总结在学习过程中遇到的c语言函数:

1、相关函数:fstat, lstat, chmod, chown, readlink, utime

头文件:#include #include
定义函数:int stat(const char * file_name, struct stat *buf);
函数说明:stat()用来将参数file_name 所指的文件状态, 复制到参数buf 所指的结构中。成功返回0,失败返回-1. stat结构体内详细信息不再赘述,可以参考其他博客资料。

使用方法:

struct stat sa;
if(stat(filename,&sa)<0)
{
return -1;
}
....
2、memset

总的作用:将已开辟内存空间 s 的首 n 个字节的值设为值 c。

#include
    
     
using namespace std;
void main()
{
char s[20];
cout<<"s大小"<
      
      

3、rand(),RAND_MAX

rand()产生随机数的一个随机函数;

RAND_MAX是C中stdlib.h中宏定义的一个字符常量: #define RAND_MAX Ox7FFF 其值最小为32767,最大为2147483647 通常在产生随机小数时可以使用RAND_MAX。
#include
       
        
#include
        
          #include
         
           using namespace std; int main(void) { srand((unsigned int)time(NULL)); double a[10]; int i; cout<
          
           




】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言程序中为什么要使用debug宏? 下一篇深入理解C语言中的移位运算

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: