Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute C Online

#include <stdio.h>

char fakeInput[]="blablafz";

char* removeDuplicate(char str[]);

int main()
{
    //printf("Hello, World!\n");
    
    printf("RESULT: %s \n", removeDuplicate(fakeInput) );
    
    return 0;
}

char* removeDuplicate(char input[]) {
int i = 0;

// temps
int repIndex = 0;
int temp     = 0;

// crveni kvadratic
int j        = 0;
char ch;

printf("Input: %s\n",input);

while((ch = input[i++] ) != '\0') // jel trenutni element eol?
{
    
    j = i; // prije smo i++ inkrementirali, j = i da j ne gleda sam sebe
    
    printf("Looking for %c \n",ch);
    
    while(input[j] != '\0') // to je vec sljedeci element.. jel element 1 eol?
    {
        printf("Checking if %c = %c \n",input[j],ch);
        repIndex = j;
        if(ch == input[repIndex]) // b= l?n b=a?n b=b?y
        {
            printf("Yup\n");
            while(input[repIndex]!='\0')
            {
                printf("Removing %c \n",input[j]);
                temp = repIndex;
                input[temp] = input[++repIndex];
    
            }
    
        } else {
            printf("Next letter.. \n");
            j++; 
            }
    
    }
}

return input;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.