【3D技术宅公社】XR数字艺术论坛  XR技术讨论 XR互动电影 定格动画

 找回密码
 立即注册

QQ登录

只需一步,快速开始

调查问卷
论坛即将给大家带来全新的技术服务,面向三围图形学、游戏、动画的全新服务论坛升级为UTF8版本后,中文用户名和用户密码中有中文的都无法登陆,请发邮件到324007255(at)QQ.com联系手动修改密码

3D技术论坛将以计算机图形学为核心,面向教育 推出国内的三维教育引擎该项目在持续研发当中,感谢大家的关注。

查看: 3033|回复: 0

[转帖]自己实现库函数strstr()

[复制链接]
发表于 2008-3-4 14:37:50 | 显示全部楼层 |阅读模式

/*
char *mystrstr(char *s, char *t)
16 {
17 if (NULL == s || NULL == t) {
18 printf("please input right string!\n");
19 return NULL;
20 }
21
22 char *s_temp; /*the s_temp point to the s*/
23 char *m_temp; /*the mv_tmp used to move in the loop*/
24 char *t_temp; /*point to the pattern string*/
25
26 s_temp = s;
27
28 /*s_temp point to the s string*/
29 for (; *s_temp != '\0'; s_temp++) {
30
31 /*the move_tmp used for pattern loop*/
32 m_temp = s_temp;
33
34 /*the pattern string loop from head every time*/
35 for (t_temp = t; *t_temp == *m_temp; t_temp++, m_temp++)
36 ;
37
38 /*if at the tail of the pattern string return s_tmp*/
39 if (*t_temp == '\0') {
40 return s_temp;
41 }
42 }
43 }

[此贴子已经被作者于2008-11-13 16:11:59编辑过]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|3D数字艺术论坛 ( 沪ICP备14023054号 )

GMT+8, 2025-2-6 09:04

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表