1.调用系统
int main(){
system("rm /home/book/fujinbing");
}
2.得到当前绝对路径,string 赋值,sting数组显示
#include <string>
#include <iostream>
using namespace std;
int main(){
char buf[1024];
getcwd(buf,1024);
printf("%s\n",buf);
string tmppath;
tmppath=buf;
cout<<buf<<endl;
cout<<buf[0]<<endl;
return 1;
}
3.去掉一行 的 0x0d回车 0x0a 换行键 0x09 水平置标符 0x20 空格 ,erase 删除
while ( ( tmpsflen > 0 ) && ( ( filepath[ tmpsflen - 1 ] == (char)0x0d )|| ( filepath[ tmpsflen - 1 ] == (char)0x0a )|| ( filepath[ tmpsflen - 1 ] == (char)0x20 )|| ( filepath[ tmpsflen - 1 ] == (char)0x09 ) ) )
{
filepath.erase( tmpsflen - 1 , 1 ) ;
tmpsflen -- ;
}
4.c++方式 得到文件流 读取1行数据
fstream tmpfp ("Config.dat",ios base :: in);
构造 tmpfp实例
string tmpstr ;
getline( tmpfp , tmpstr )
5.时间,时间格式
#include <time.h>
#include <stdio.h>
int main(){
time_t lt;
printf("%ld\n",lt); //
lt=time(NULL);
printf("%ld\n",lt); //据1900的时间戳
struct tm *st;
st=localtime(<);
printf("%d\n",st->tm_sec);
printf("%d\n",st->tm_min);
printf("%d\n",st->tm_hour);
printf("%d\n",st->tm_mday);
printf("%d\n",st->tm_mon);
printf("%d\n",st->tm_year);
printf("%d\n",st->tm_wday);
printf("%d\n",st->tm_yday);
printf("%d\n",st->tm_isdst);
return 1;
}
struct tm
{
int tm_sec; /* Seconds. [0-60] (1 leap second) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
#ifdef __USE_BSD
long int tm_gmtoff; /* Seconds east of UTC. */
__const char *tm_zone; /* Timezone abbreviation. */
#else
long int __tm_gmtoff; /* Seconds east of UTC. */
__const char *__tm_zone; /* Timezone abbreviation. */
#endif
};
6.文件属性
1 函数都是获取文件(普通文件,目录,管道,socket,字符,块)的属性。
函数原型
#include <sys/stat.h>
int stat(const char *restrict pathname, struct stat *restrict buf); 提供文件名字,获取文件对应属性。
int fstat(int filedes, struct stat *buf); 通过文件描述符获取文件对应的属性。
int lstat(const char *restrict pathname, struct stat *restrict buf); 连接文件描述符,获取文件属性。
2 文件对应的属性
#include <stdio.h>
#include <string>
#include <sys/stat.h>
using namespace std;
int main(){
struct stat at;
string filename ="./aa";
stat(filename.c_str(),&at);
printf("%d\n",at.st_ctime);
return 1;
}
struct stat {
mode_t st_mode; //文件对应的模式,文件,目录等
ino_t st_ino; //inode节点号
dev_t st_dev; //设备号码
dev_t st_rdev; //特殊设备号码
nlink_t st_nlink; //文件的连接数
uid_t st_uid; //文件所有者
gid_t st_gid; //文件所有者对应的组
off_t st_size; //普通文件,对应的文件字节数
time_t st_atime; //文件最后被访问的时间
time_t st_mtime; //文件内容最后被修改的时间
time_t st_ctime; //文件状态改变时间
blksize_t st_blksize; //文件内容对应的块大小
blkcnt_t st_blocks; //伟建内容对应的块数量
};
7.编译时链接库 -lpthread链接pthread库。-ltr链接clock_gettime函数相关库 -lssl 链接 md5相关
分享到:
相关推荐
这是我积累的历年C语言上机答案,很权威哦,有需要的可以下来看看,很不错,对C语言上机很有帮助
本人积累的一些小图标,个人认为还是很漂亮的。C/S,B/S系统绝对用的到。
C语言的最大特点是:功能强、使用方便灵活。C编译的程序对语法检查并不象其它高级语 ...看着有错的程序,不知该如何改起,本人通过对C的学习,积累了一些C编程时常犯的错 误,写给各位学员以供参考。
C语言的最大特点是:功能强、使用方便灵活。C编译的程序对语法检查并不象其它高级语言那么严格,这就给...看着有错的程序,不知该如何改起,本人通过对C的学 习,积累了一些C编程时常犯的错误,写给各位学员以供参考。
关于c语言的,从网站、论坛中节选的文章,介绍了c中的难点,和学习心得、经验,还有一份教程,较简单。是学习c的比较好的资料。
在以太网领域,经历多年的耕耘和发展,H3C积累了大量业界领先的知识产权和专利,产品覆盖园区交换机和数据中心交换机产品,从核心骨干到边缘接入10多个系列上百款产品,并且全部通过中国信息产业部、Tolly Group、...
C语言的最大特点是:功能强、使用方便灵活。C编译的程序对语法检查并不象其它高级语言那么严格,这就给...看着有错的程序,不知该如何改起,本人通过对C的学习,积累了一些C编程时常犯的错误,写给各位学员以供参考。
一些日常的C、C++代码积累.zip
C语言中C89和C99的中文文档,网上搜索积累下来的分享给大家
C语言的最大特点是:功能强、使用方便灵活。C编译的程序对语法检查并不象其它高级语言那么严格,这就给...看着有错的程序,不知该如何改起,本人通过对C的学习,积累了一些C编程时常犯的错误,写给各位学员以供参考。
高/低积累型菜心抗氧化系统对CIP胁迫响应的差异,严青云,向垒,研究了高、低积累型菜心(油青四九菜心、油绿粗苔菜心)抗氧化系统对喹诺酮类环丙沙星抗生素(CIP)胁迫响应的差异。结果表明,不
使用Keil+C调试某系统时积累的一些经验
文章总结了我们使用Keil C调试某系统时积累的一些经验。
C语言的最大特点是:功能强、使用方便灵活。C编译的程序对语法检查并不象其它高级语言那么严格,这就给...看着有错的程序,不知该如何改起,下面将本人和一些网友积累了一些C编程时常犯的错误,写给各位学员以供参考。
C 语言拔高训练,有助于综合提升c语言的读能力以及积累代码量
C语言基础教程/心得/QA/总结文档,c语言从零到1全学习路线与资料。C 语言是一种非常重要的编程语言,适合初学者入门。你可以从学习基本的语法...在学习过程中多思考、多实践,积累经验,你将逐渐掌握C语言的编程技能。
这是多年来积累的C&C++试题,包含试题答案、面试心得。是学习心血的总结,希望对大家有所帮助。欢迎下载!
C语言常见错误 C语言的最大特点是:功能强、使用方便灵活。C编译的程序对语法检查并不象其它...看着有错的程序,不知该如何改起,本人通过对C的学习,积累了一些C编程时常犯的错误,写给各位学员以供参考。——引自作者
绝对经典,学习过了就会有收获,成功是需要付出的,兴趣也需要积累