一、八进制:
int a = 015; //换算成十度进制为 13
二、字符串操作一些重要的c函数,超级好用
1、char * strchr (const char str, int c); //strchr() 用来查找某字符在字符串中首次出现的位置
2、char * strrchr (const char str, int c);//strrchr() 用来查找某字符在字符串中最后一次次出现的位置
3、strncpy()
可以用strncpy()函数
#include <string.h>
char sub[20];
strncpy(sub,string+12,13) /将string中从string[12]开始的13个数字复制到sub中/
4、sscanf
char a[]="34+65";
int i,j;
sscanf(a,"%d+%d",&i,&j);
printf("%d\n%d",i,j);
5、时间戳和时间之间转化,记录下
struct tm *p;
timep=1384936600;
printf("pppppstamp:%d\n",timep);
p=localtime(&timep);
data->tm_year =p->tm_year+1900;
data->tm_mon =1+p->tm_mon;
data->tm_mday = p->tm_mday;
data->tm_hour =p->tm_hour;
data->tm_min =p->tm_min;
data->tm_sec =p->tm_sec;
data->tm_msec = 0;
printf("%d-%d-%d-%d-%d-%d\n",data->tm_year,data->tm_mon,data->tm_mday,data->tm_hour,data->tm_min,data->tm_sec);
timeChange(data);
return 0;
反之转化
time_t timep;
struct tm p;
p.tm_year=2013-1900;
p.tm_mon=11-1;
p.tm_mday=20;
p.tm_hour=8;
p.tm_min=36;
p.tm_sec=40;
/p.tm_year=data->tm_year-1900;
p.tm_mon=data->tm_mon-1;
p.tm_mday=data->tm_mday;
p.tm_hour=data->tm_hour;
p.tm_min=data->tm_min;
p.tm_sec=data->tm_sec;/
timep=mktime(&p);
printf("time%d\n",timep);
return timep;
网友评论