可怜的小猪c语言代码大全,c语言编程

#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;

}

===========================================================

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值