To Write a C program to remove the repeated characters in
the entered expression or in entered characters(i.e)
removing duplicates.

Answer Posted / anbu

/Made few corrections...

int remove_duplicates(char *str)
{
int char_check=0;
int i,j;
char ch;

char filterstr[256]; // new

if(str == NULL)
return 0;

/* check from 1st character in the string */
while(str[char_check]) {

ch = str[char_check];

i = j = char_check+1;

filterstr[0] = str[0]; // added

/* logic to remove the repeated character */
while(str[i]) {
if(str[i] != ch) {
filterstr[j] = str[i]; //modifid
j++;
}
i++;
}
filterstr[j]='\0'; //modified

str = filterstr; //added

char_check++;
}
printf("String after removing duplicates : %
s\n",filterstr);
return 1;
}

Is This Answer Correct ?    13 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

2136


Write a routine to implement the polymarker function

4375


Design an implement of the inputs functions for event mode

2957


could you please send the program code for multiplying sparse matrix in c????

3067


Write a program to model an exploding firecracker in the xy plane using a particle system

3686






How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

1928


How can you relate the function with the structure? Explain with an appropriate example.

2915


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1067


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

4140


Develop a routine to reflect an object about an arbitrarily selected plane

2992


write a simple calculator c program to perform addition, subtraction, mul and div.

3143


What is full form of PEPSI

1863


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2325


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2258


Cluster head selection in Wireless Sensor Network using C programming language.

3107