[root@controller /]# cat time.c
#include
#include
#include
int main(int argc,char **argv)
{
time_t time_now;
struct tm *curr_time = NULL;
time(&time_now);
curr_time = localtime(&time_now);
printf("time_now:[%ld]\n",time_now);
printf("localtime[%d.%02d.%02d %02d:%02d:%02d]\n",(1900 + curr_time->tm_year),(1 + curr_time->tm_mon),curr_time->tm_mday,curr_time->tm_hour,curr_time->tm_min,curr_time->tm_sec);
return 0;
}
[root@controller /]#
=========================================================
[root@controller /]# cat str.c
#include
#include
#include
int main()
{
char *p=NULL;
char *a="1111Gib";
p=a+(strlen(a)-3);
if(*p == 'G')
{
printf("aaaaaaaaaaaaaaa");
}
printf(p);
return 0;
}
==========================================================
int main()
{
char downflow[32]={0};
//get_results_cmd(downflow, "cat /haha.ini");
snprintf(downflow,32,"%d",0);
printf("%s\n",downflow);
return 0;
}
[root@controller /]#
==============================================
[root@controller /]# cat aaa.c
#include
#include
#include
int main()
{
int a = -3;
if(a == -3)
{
printf("hahahahahhaha\n");
}
return 0;
}
[root@controller /]#
=======================================================
[root@controller /]# cat cc.c
#include
int main()
{
char *a="3.67";
char b[16]={0};
float f=atof(a);
printf("%lf\n",f);
snprintf(b, 16,"%f",atof(a));
printf("%s\n",b);
return 0;
}
[root@controller /]#
==================================================
[root@controller /]# cat echo.c
#include
#include
#include
int main()
{
char temp1[128];
bzero(&temp1, sizeof(temp1));
snprintf(temp1, sizeof(temp1), "echo \"%s %s %s\" >> /etc/ipv6_config", "eth0", "1.1.1.1/24", "2.2.2.2/24");
system(temp1);
return 0;
}
[root@controller /]
=====================================================
[root@controller /]# cat float.c
#include
#include
#include
int bbb(float *haha)
{
*haha=2.2;
}
int main()
{
float a=200.2;
float b=0;
b = a/atoi("2");
printf("%.1f",b);
if(b > 100)
{
b = 100;
}
//snprintf(cpuUsed, sizeof(cpuUsed), "%.1f", vcpustat_tmp);
//float b=2.1;
//float c = 0;
//float d = 0;
//c=a+b;
//if(a>100)
//{
//a=100;
printf("%.1f",b);
===========================================================
[root@controller /]# cat haha.c
#include
#include
#include
int get_vpairint_by_vpairflow(char *vpair_int, char *vpair_flow)
{
int len = 0 ;
len = strlen(vpair_flow);
char *t = &vpair_flow[len-1];
strncpy(vpair_int,vpair_flow,len-1);
if(atoi(t) == 0 )
{
strcat(vpair_int,"1");
}
else
{
strcat(vpair_int,"0");
}
return 0;
}
int main()
{
char *a="vpair1_1";
char b[32]={0};
get_vpairint_by_vpairflow(b, a);
printf("--------------------------%s",b);
return 0;
}
[root@controller /]#
===========================================================
[root@controller /]# cat hanzi.c
#include
#include
#include
#include"errorNo.h"
int main()
{
char a[512]={0};
char b[64]={0};
getErrInfoVm(2041,a,512);
snprintf(b,12,"%s",a);
printf("%s",a);
printf("%s",b);
return 0;
}
[root@controller /]#
===========================================================
// if(vpair_name == NULL || strlen(vpair_name) == 0)
// {
// ret =-1;
// }
return ret;
}
===========================================================
int main()
{
char modifySrcIp[64] = {0};
char *bufTmp= NULL;
char srcIp[64] = { 0 };
strcpy(srcIp, "169.254.255.2");
bufTmp=strchr(srcIp,'.');
strncpy(modifySrcIp,srcIp,bufTmp-srcIp);
strcat(modifySrcIp,bufTmp+1);
printf("%s",modifySrcIp);
return 0;
==========================================================
[root@controller /]# cat mac.c
#include
#include
#include
int main()
{
char mac[64]={0};
char newmac[64]={0};
char *p = NULL;
snprintf(mac,sizeof(mac),"%s","25:4a:ef:ce:24:d9");
printf("%s\n",mac);
p=mac;
snprintf(newmac,sizeof(newmac),"%s%s","aa",p+2);
printf("%s\n",newmac);
return 0;
}
===========================================================
阅读(2543) | 评论(0) | 转发(0) |