Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1056427
  • 博文数量: 573
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 66
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-28 16:21
文章分类

全部博文(573)

文章存档

2018年(3)

2016年(48)

2015年(522)

分类: LINUX

2015-12-02 16:49:00


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <signal.h>
  4. #include <strings.h>
  5. #include <stdlib.h>
  6. #include <sys/types.h>
  7. #include <sys/socket.h>
  8. #include <netinet/in.h>
  9. #include <netdb.h>
  10. #include <ctype.h>
  11. #include <setjmp.h>
  12. #include <sys/time.h>
  13. #include <stdarg.h>

  14. int main(int argc, char * * argv)
  15. {
  16.     int a, b, c;
  17.     printf("sizeof(char)=[%d], sizeof(int)=[%d]\n", sizeof(char), sizeof(int));
  18.     sprintf(&a, "0124");
  19.     printf("a=[%d]\n", a);
  20.     b = ntohl(a);
  21.     printf("b=[%d]\n", b);
  22.     c = atoi(&a);
  23.     printf("c=[%d]\n", c);
  24.     
  25.     int d = 123;
  26.     int len;
  27.     len=htonl(d);
  28.     printf("d=[%d]\n", d);
  29.     printf("len=[%d]\n", len);
  30.     
  31.     /*read,write 互相约定好,一起转才可以*/
  32.     int length;
  33.     length=ntohl(len);
  34.     printf("length=[%d]\n", length);
  35.     
  36.     printf("============================\n");
  37.     int host = 1;
  38.     host=htonl(host);
  39.     printf("host=[%d]\n", host);
  40.     printf("============================\n");

  41.     return 0;
  42. }

阅读(723) | 评论(0) | 转发(0) |
0

上一篇:自己实现sprintf

下一篇:realloc函数

给主人留下些什么吧!~~