#include <stdio.h>
int mystrlen(char pstr[])
{
int count=0;
while(pstr[count]!='\0')
{
count++;
}
return count;
}
int main(int argc, const char *argv[])
{
char str[100]="hello";
int x;
x=mystrlen(str);
printf("count=%d\n",x);
return 0;
}
#include <stdio.h>
void mystrcpy(char dst1[],char src1[])
{
int i=0;
while(1)
{
dst1[i]=src1[i];
if(src1[i]=='\0')
break;
i++;
}
}
int main(int argc, const char *argv[])
{
char dst[100];
char src[32]="hello";
mystrcpy(dst,src);
printf("dst=%s\n",dst);
return 0;
}
#include <stdio.h>
2 int mystrcmp(char buf1[],char str1[])
3 {
4 int res=0;
5 int i;
6 for(i=0;buf1[i]!='\0'||str1[i]!='0';i++)
7 {
8 res=buf1[i]-str1[i];
9 if(res!=0)
10 {
11 break;
12 }
13 }
14 return res;
15 }
16 int main(int argc, const char *argv[])
17 {
18 char buf[100]="helloworld";
19 char str[10]="hellochina";
20 int x;
21 x=mystrcmp(buf,str);
22 printf("x=%d\n",x);
23
24 return 0;
25 }
#include <stdio.h>
2 void mystrcat(char s10[],char s20[])
3 {
4 int i=0;
5 for(i=0;s10[i]!=0;i++)
6 {
7 }
8 int j=0;
9 for( ;s20[j]!=0;i++,j++)
10 {
11 s10[i]=s20[j];
12 }
13 s10[i]='\0';
14 }
15 int main(int argc, const char *argv[])
16 {
17 char s1[100]="hello";
18 char s2[10]="world";
19 mystrcat(s1,s2);
20 printf("s1=%s\n",s1);
21
22 return 0;
23 }