C++ Program – Remove duplication of the word
by Nideesh C on May 11, 2011 · 0 comments
in C++
//Downloaded From theonlinetutorials.com
//Source code
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void dop(char s[])
{
char a[100],b[100];
a[0]=NULL;
b[0]=NULL;
int flag=0,sa=0;
for(int i=0;i<=strlen(s);i++)
{
if(s[i]==' '||s[i]==NULL)
{
b[sa]=' ';
sa++;
b[sa]=NULL;
flag=1;
}
else
{
b[sa]=s[i];
sa++;
}
if(flag==1)
{
if(strcmp(a,b)==0)
{
for(int j=(i-sa);j<=strlen(s);j++)
{
s[j]=s[j+sa];
}
i=i-sa;
}
flag=0;
sa=0;
strcpy(a,b);
}
}
}
int main()
{
char s[100];
cout<<"Enter a String"<<endl;
gets(s);
dop(s);
cout<<"Formated string is"<<endl;
cout<<s;
getch();
return 0;
}
Not Satisfied ? Just search & get the result
Related posts:
- C++ Program – Reversing each word in a string
- Sample – Program to enter a string and find its length.
- C++ program – Lowercase Vowels
- C++ Program – Count no of repetitions of a digit
- C Program – To replace a word by another word in a given string
Tagged as:
C++ Program - Remove duplication of the word,
CPP Program - Remove duplication of the word,
Remove duplication,
Remove duplication of the word,
Remove duplication of the word in C++,
Remove duplication of the word in CPP,
Word duplication removal
Me, freelance system administrator having the qualification of Diploma in Electronics & Tele-communication + MCSE + CCNA + CST + 5 years of experience in IT field.
If you like This post, you can follow TheOnlineTutorials on Twitter.
Contact me Via email: support@theonlinetutorials.com
Subscribe to feed via Feed or EMAIL to receive instant updates.
Legal Disclaimer:All information found on the site is without any implied warranty of fitness for any purpose or use whatsoever. Content author/site administrator is not responsible for any loss occurred due to mistakes in this tutorial. Use this tutorial website at your own risk.