- 博客(8)
- 收藏
- 关注
原创 atoi和itoa的实现
#include int str2num(const char *s){ int i; char c; for (i = 0; 0 <= (c = *s) && c <= 9; ++s) i = i*10 + c - 0; return i;}d
2008-06-19 09:45:00 725
原创 计算一个字符的二进制表示中有几个1
#include void ch2binary( char v ){ int nBits; int i; int numOfOne = 0; nBits = sizeof( char ) << 3; //计算有多少位 for( i = nBits - 1; i >= 0; i -- ) {
2008-06-18 15:39:00 911
原创 linux网络地址转换函数
在socket编程时,会出现指定了ip,端口号,却连不上,这是因为网络地址跟本地主机地址的字符顺序不一样导致的。在linux下提供了一些操作函数,如下: unsigned long int htonl(unsigned long int hostlong);用来将参数指定的32位hostlong 转换成网络字符顺序。 unsigned short int htons(unsigne
2008-04-02 10:35:00 612
原创 创建虚拟文件系统
1、创建空文件dd if=/dev/zero of /tmp/disk-image count=204802、创建文件系统 mke2fs -q /tmp/ disk-image 3、挂载文件系统mkdir /tmp/virtual-fsmount -o loop=/dev/loop0 /tmp/disk-image /tmp/virtual-fs可以将光盘直接copy到
2008-02-25 16:03:00 469
原创 利用/dev/random生成随机数
int random_number(int min, int max)...{ static int dev_random_fd = -1; char *next_random_byte; int bytes_to_read; unsigned random_value; assert( max > min ); if( dev_random_fd == -
2008-02-25 15:42:00 1897
原创 c++试题
年初又是一个跳槽的高峰期,多少程序员满怀希望的去面试,却往往失足于一些细节,今贴出一些c++经典试题,希望对大家有所帮助。 找错题 试题1:void test1(){ char string[10]; char* str1 = "0123456789"; strcpy( string, str1 );} 试题2:void test2(){ char string[10], str1
2008-02-19 09:51:00 490
原创 lInterprocess communication (Linux)
Five chief types of interprocess communication:1. Shared momery2. Mapped momery3.Pipe4. FIFO5.Socket
2007-12-10 13:12:00 381
原创 linux socket programming
1. server socket s life cycle: 1) creation a connection-style socket; 2) binding an address to its socket 3) placing a call to listen that enables connections to the socket 4)p
2007-12-10 12:58:00 469
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人