Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks

Saturday 17 November 2012

Write a program to find the length of the given string strlen() using pointers in C language examples?

Length of the string,string length,C string length,find string length,length of the string using pointers,find length of the string in C, Write a program to find the length of the given string using pointers in C language,string length program,find string length using pointers in C,find strlen()


 String length

   The given program is for the find the length of the given string.

                           #include<stdio.h>
                            int stringlength(char *);

                            main()
                            {
                                  char source[100];
                                     int length;

                                    printf("Enter String\n");
                                    scanf("%[^\n]",source);

                                       length = stringlength(source);

                                      printf("The length of the string is : %d\n",length);
                             }
                             
                               int stringlength(char *str)

                              {
                                     int count = 0;
                   
                                          while(*str != '\0')

                                               {
                                                     *str++;
                                                       count++;
                                               }
                                   return count;
                               }

                 Output:
                               Enter String
                                 beonlyone
                                 The length of the string is : 9 

0 comments:

Post a Comment