Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stddef.h>
- #include <stdio.h>
- unsigned int mystrlen(char *s){
- unsigned int i=0;
- if (s==NULL)
- return NULL;
- do {
- i++;
- } while (s[i]!=NULL);
- return i;
- }
- char *mystrchr(char *s, char c){
- unsigned int i=0;
- if (s==NULL)
- return NULL;
- while ((s[i]!=c) && (i<mystrlen(s)))
- i++;
- if (s[i]!=c)
- return NULL;
- return s[i];
- }
- char *mystrcpy(char *dest, char *src){
- int i;
- if (dest==NULL || src==NULL)
- return NULL;
- for (i=0;i<=mystrlen(src);i++)
- dest[i]=src[i];
- return dest;
- }
- char *mystrcat(char *dest, char *src){
- unsigned int i,leng;
- leng=mystrlen(dest);
- if (dest==NULL || src==NULL)
- return NULL;
- for (i=0;i<mystrlen(src)+1;i++)
- dest[i+leng]=src[i];
- return dest;
- }
- int mystrcmp(char *s1, char *s2){
- int i=0;
- if (s1==NULL || s2==NULL)
- return NULL;
- do{
- if (s1[i]>s2[i])
- return 1;
- if (s1[i]<s2[i])
- return -1;
- i++;
- } while (mystrlen(s1)==i-1);
- if (i==mystrlen(s2))
- return 0;
- else
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement