Removing duplicate elements in a string

0

This programs removes dulplicate elements in a string without using an additional array
//Time complexity O(n^2)
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
void removeDuplicate(char* str){
if(str==”)
return;
int pivot=1;
int len=strlen(str);
//i runs from 2nd element to last element because j runs from first element to pivot
//element and we need not compare same elements so i and j neve have same value at same time
for(int i=1;i<len;i++){
int j;
//make all elements before the pivot as unique

for(j=0;j<pivot;j++)
if(str[j]==str[i])
break;
if(j==pivot){
//if j==pivot (str to str+pivot) is a unique subarray where str[pivot]=str[i]

str[pivot]=str[i];
pivot++;
}

}
str[pivot]=”;

}
int main(){
char str[]=”asddfffafffafffafaffafaf”;
removeDuplicate(str);
cout<<str;

}