Monday, February 18, 2013

C Language Example # 18 String Example : Count Number of Words from String

C Language Example # 18 String Example : Count Number of Words from String.

* Lets now starts with String Header File concept.
* Example of C Language String : Count Number of words from String 

//Written by Latest Technology Guide    
//Title : C Language Example # 18 String Example : Count Number of Words from String.
  
#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
{
clrscr();
int i,words=1;
char ch[30]={0};

printf("\n Now Enter Text : ");
gets(ch);

i=0;
do
{
if(ch[i]==32)
words=words+1;

i++;
}while(ch[i]!=NULL);


printf("\n\t\t *****: Detail Description :***** ");
printf("\n Number of Words in String is = %3d",words);
getch();
}

Output:

* You can find out Total number of words exist in string.


--------------------------------------------------------------------------------
Explanation of C Programming Language Example #  18 String Example : Count Number of Words from String.

* Enter String of your choice 
* In output you will find Number of words in string is : ??.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

1 comment:

  1. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. word counter tool

    ReplyDelete