EmbLogic's Blog

function of strlen

1 #include<stdio.h>
2 #include<stdlib.h>
3 char* ip()
4 {
5          char *s1,ch;
6          int i=0;
7          s1=(char*)malloc(sizeof(char));
8          while(1)
9         {
10                 scanf(“%c”,&ch);
11                 s1=realloc(s1, i+1*sizeof(char));
12                 if(ch==10)
13                 break;
14                 s1[i]=ch;
15                 i++;
16         }
17         printf(“%s\n”,s1);
18         return s1;
19 }
20 int stlen(char*s1)
21 {
22         int i=0;
23         while(1)
24         {
25                 if(s1[i]==0)
26                 break;
27                 i++;
28         }
29         printf(“%d”,i);
30         return i;
31
32 }
33
34 main()
35 {       char * s1;
36         s1=ip();
37         stlen(s1);
38 }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>