易截截图软件、单文件、免安装、纯绿色、仅160KB

C字符串处理函数的实现

本文来自: http://blog.pfan.cn/xiuandfang/24935.html
标签:C C ++ string String 数据结构 
C字符串处理函数的实现

C字符串处理函数的实现(Linux)
#include <stddef.h>
 char * ___strtok = NULL;
 
 char * strcpy(char * dest,const char *src)
 {
         char *tmp = dest;
 
         while ((*dest++ = *src++) != '\0')
                 /* nothing */;
         return tmp;
 }
 
 char * strncpy(char * dest,const char *src,size_t count)
 {
         char *tmp = dest;
 
         while (count-- && (*dest++ = *src++) != '\0')
                /* nothing */;
 
         return tmp;
 }
 
 char * strcat(char * dest, const char * src)
 {
         char *tmp = dest;
 
         while (*dest)
                 dest++;
         while ((*dest++ = *src++) != '\0')
                 ;
         return tmp;
 }
 
 char * strncat(char *dest, const char *src, size_t count)
 {
         char *tmp = dest;
         if (count) {
                 while (*dest)
 


相关文档:

将类成员函数用做C回调函数

将类成员函数用做C回调函数 提出问题: 回调函数是基于C编程的Windows SDK的技术,不是针对C++的,程序员可以将一个C函数直接作为回调函数,但是如果试图直接使用C++的成员函数作为回调函数将发生错误,甚至编译就不能通过。分析原因:普通的C++成员函数都隐含了一个传递函数作为参数,亦即“this”指针,C++通过 ......

Linux下C语言编程 文件的操作

前言: 
    我们在这一节将要讨论linux下文件操作的各个函数. 
1.文件的创建和读写 
2.文件的各个属性 
3.目录文件的操作 
4.管道文件 
--------------------------------------------------------------------------------
1。文件的创建和读写 
......

linux上c语言 获得网络接口的统计值

这个东东,蛮好玩的。其实就是读取了/proc/net/dev 文件。
struct netdev_stats {
    unsigned long long rx_packets_m;    /* total packets received       */
    unsigned long long tx_packets_m;     &nbs ......

C/C++ 面试题

第一题:
下面程序的输出结果?
#include <stdio.h>
#include <iostream>
void main()
{
char str1[] = "";
char str2[] = "";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "a ......

c函数scanf(),printf()等常用格式字符串

%d   短整形,一般占两个字节
%u   无符号短整形
%ld  长整形,一般占四个字节
%c   字符型
%s    字符串
主要用在输入输出函数:scanf(),printf()里
\a:蜂鸣,响铃
\b:回退:向后退一格
\f:换页
\n:换行,光标到下行行首
\r:回车,光标到本行行首
\t:水平制表
\v:垂直制表 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号