C Language Example # 23 Example : Find character from string.
* Find character from string.
//Written by Latest Technology Guide
//Title : C Language Example # 23 Example : Find character from string
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
clrscr();
int i,total=0;
char ch[30]={0},find;
printf("\n Enter String : ");
gets(ch);
printf("Enter Character To Find : ");
scanf("%c",&find);
printf("\n ********** : Detail Description :**********\n\n");
i=0;
do
{
if(ch[i]==find)
{
printf("\n%4d",i);
total=total+1;
}
i++;
}while(ch[i]!=NULL);
printf("\n\t\tTotal Character (%c) Found : %3d",find,total);
getch();
}
Output:
* Program will display that entered character is found ?? times.
--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 23 Example : Find character from string
* Enter You String
Explanation of C Programming Language Example # 23 Example : Find character from string
* Enter You String
* Then enter character you want to search in a string.
* It will display that how many times number appears in a string.
* It will display that how many times number appears in a string.
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.
No comments:
Post a Comment