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

【题目4】如何自己实现C函数strstr()

解题思路: 这个网络上已经有很多答案,这里
列举一个复杂度为0(m*n)的例子。实现的原理
很简单,顺序遍历要查找的字符串,如果没有找
到,字符串指针往前一位,再往后比较要查找的
字符串(模式串),如下图所示:
a b c d  d  d a d a c a b d a d d d a d c k
             ->
            d a d a
char* strstr(const char* s1, const char* s2)
{
      if(s1 == NULL || s2 == NULL)
           return NULL;
      while(*s1)
      {  
           while(1)
         {
               int i = 0;
               if(s2[i]  == NULL)
                    return (char*)s1;
               if(s2[i] != s1[i])
                    break;
               i++;
         }
         s1++;
     }
      return NULL;
}


相关文档:

c 的 struct,没有结构体名的结构体数据类型

一直对结构体弄的模糊,今天终于有机会澄清了。有个错:不明白没有结构体名的结构体如何像结构体名一样使用。
typedf struct                               st ......

C#发送邮件代码 (B/S、C/S皆可用)

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using  ......

Lua调用C函数

根据《programming in lua》第26章的内容,我做出来的如下:
 
 
1.
首先,我的Lua目录为:D:\lua5.1\
环境为 windows ; VC++express edition 2008 ; Lua5.1.4 ; Notepad++
 
当然,你需要在VC++2008中配置好lua:
 
 
 
这里先不多做解释,假设你已经配置好了。
 
2.
& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号