Removing Characters Of A String

Removing Duplicate Characters Of A String

Page 1 of 1

4 Replies - 8661 Views - Last Post: 27 November 2009 - 02:21 AM Rate Topic: -----

#1 dannie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-November 09

Removing Characters Of A String

Post icon  Posted 27 November 2009 - 01:49 AM

// Removing Duplicate Characters.
#include<iostream.h>
#include<conio.h>
#include<string.h>
void dup_delete(char*);
int main()
{
const int n=50;
char input[n];
cout<< "Enter Your Characters(Max=50):";
cin.get(input,n);
dup_delete(input);
return 0;
}
void dup_delete(char *input)
{
int i,j,k=0,count=0,z=0;
char output[50];
char dup[50];
for(i=0;i<50;i++){
for(j=i+1;j<50;j++)
if(input[i]==input[j]) count++;
if(count>1)
dup[k]=input[i];
k++;
count=0;
}
for(i=0;i<50;i++){
for(j=0;j<50;j++)
if(input[i]==dup[j]) break;
if(j==50) output[z]=input[i];
z++;
}
cout<< "The Non-Duplicate Characters Is:" << output;
getch();
}



Is This A Good Question/Topic? 0
  • +

Replies To: Removing Characters Of A String

#2 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 387
  • View blog
  • Posts: 1,663
  • Joined: 16-May 09

Re: Removing Characters Of A String

Posted 27 November 2009 - 01:57 AM

post your codes between [code ] and [/ code] tags (without space in them).
Where is your question/problem ?
Was This Post Helpful? 0
  • +
  • -

#3 ethereal1m  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 227
  • Joined: 30-June 09

Re: Removing Characters Of A String

Posted 27 November 2009 - 01:57 AM

what is your question? and your closing code tag should have used forward slash instead of backslash
Was This Post Helpful? 0
  • +
  • -

#4 dannie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-November 09

Re: Removing Characters Of A String

Post icon  Posted 27 November 2009 - 01:59 AM

Enter an array of characters from the user and remove all the duplicate characters. (You may use a
second array for this.) For example,
INPUT: a e s e d f k d m n v s o j n
OUTPUT: a f k m v o j
Was This Post Helpful? 0
  • +
  • -

#5 ethereal1m  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 227
  • Joined: 30-June 09

Re: Removing Characters Of A String

Posted 27 November 2009 - 02:21 AM

View Postdannie, on 27 Nov, 2009 - 12:59 AM, said:

Enter an array of characters from the user and remove all the duplicate characters. (You may use a
second array for this.) For example,
INPUT: a e s e d f k d m n v s o j n
OUTPUT: a f k m v o j

i don't know what happened here, you separate your post from your original thread, anyway see the comment I made there....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1