Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Saturday, February 14, 2015

C program to count number of words in a string


C program to count number of words in a string

#include<stdio.h>
#include<conio.h>

void main()
{
int i,words=1;
char str[100];
clrscr();
printf("Enter a string:");
gets(str);
for(i=0;str[i]!=
Read more »

Wednesday, February 11, 2015

C C Program to Find Substring in String Pattern Matching

Pattern matching refers to find the position where a string pattern appears in a given string. If the requird string is not present in given text, then it returns the value zero.

If the required string is present in a given string, it returns the position of occurrence of required string or substring.

Also Read: C program to concatenate two strings without using strcat() function


C Program


#include<stdio.h>

int main()
{
int i,j,temp;
char str[100]={"This is a pattern matching"};
char substr[20]={"pattern"};

for(i=0;str[i]!=
Read more »

C program to find length of a string


C program to find length of a string

#include<stdio.h>
#include<conio.h>

void main()
{
int i;
char str[50];
clrscr();
printf("Enter a string:");
gets(str);

for(i=0;str[i]!=
Read more »