|
总结在学习过程中遇到的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<
|