中文字符处理函数集, 最底层函数, 基于GB18030
摘要:判断首字符的字节数。 返回值小于2, 表明首字符不是中文./****************************************************************************** Function: GetCharSize Description: This function return the size of lead character of spec...
阅读全文
一个问题的三个实现 --- 关于指针的传递
摘要:以下三个实现都是用来通过全局变量serverIP, 在mycalloc()分配内存并附值, 最后再在主函数中显示!!////////////////////////////////////////////#include <stdio.h> #include <stdlib.h>#include <string.h>char *serverIP = NULL; ...
阅读全文
[讨论]fgetc, EOF 及其它
摘要:约定编译器为 gcc2/x86:所以 char, unsigned char 为 8 位, int 为 32 位 (1) 字节的读取 在正常的情况下, getc 以 unsigned char 的方式读取文件流, 扩张为一个整数,并返回. 换言之, getc 从文件流中取一个字节, 并加上24个零,成为一个小于256的整数,然后返回. int c;while ((c = fgetc (rfp))!...
阅读全文
自已实现fflush(stdin)
摘要://///////////////////////////////////////////////////////////////// #include <stdio.h> #include <string.h> #define STR_BUFFSIZE 5 void myfflush(FILE *stream) { char buffer[STR_BUFFSIZE]; w...
阅读全文
关于setbuf()缓存的设置 fgets()读入一行字符串
摘要:/*输入:2 12345 abcde 希望输出: 0:12345 1:abcde*/#include <stdio.h>#include <stdlib.h>#include <string.h>int main( void ){ char **instr, **p; int i, j; printf( "num: " ); scanf( "%d", &...
阅读全文
两个int类型的数据,不用任何的判断语句如if、switch、?:等,找出其中的大值
摘要://两个int类型的数据,不用任何的判断语句如if、switch、?:等,找出其中的大值#include <stdio.h>/*intmax( int x,int y ){ int buf[2] = { x, y }; unsigned int z; z = x - y; z >>= 31; return buf[z];}*/intmax( int x,int y ){ i...
阅读全文
返回指定文件系统的大小及空闲大小
摘要://返回指定文件系统的大小及空闲大小#include <sys/vfs.h>#define M(x) (x)*(st.f_bsize/1024)intmain( int argc, char *argv[] ){ struct statfs st; char *fs; int r; fs = "/etc/"; if(argc > 1) fs = argv[1]; r = stat...
阅读全文
编译动态库的一个例子
摘要:源文件为main.c, x.c, y.c, z.c,头文件为x.h,y.h,z.h 现在我编译为动态库(*.so)文件.# 生成动代连接库,假设名称为libtest.so gcc x.c y.c z.c -fPIC -shared -o libtest.so # 将main.c和动态连接库进行连接生成可执行文件 gcc main.c -L. -ltest -o main # 输出LD_LIBRAR...
阅读全文