jituTechnology

jituTechnology

A program to find the length of given string using pointer and function.

A program to find the length of given string using pointer and function.

Codes
/*A program to find the length of given string using pointer and function*/
/*Programed by          Jitendra Kr Yadav
                        10116
                        2Apr,2011*/
#include<stdio.h>
#include<conio.h>
main()
{
char string[20];
int count=0;
char *ptr;
printf("Enter the string: ");
gets(string);
for(ptr=&string[0];*ptr!='\0';ptr++)
if(*ptr!=' ')
count+=1;
else
continue;
printf("Number of characters = %d.\n\n",count);
printf("Press any key to continue...");
getch();getch();
}

 

Output
Enter the string: Hello there
Number of character = 10.

Press any key to continue…

Add a comment

Comments (1)

  1. Josue MeskeApril 5, 2012 Reply
    Hello.This post was extremely interesting, especially since I was browsing for thoughts on this topic last Saturday.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930