Original Post
void replace_string_with_stars(char*str)// i must replace the string with 5 stars { char arr[60]; strcpy(arr,str);//lets assume that str is (aaahftgaaahftdsgaaa) cout<<"enter astring"<<endl; while(cin.get()!='\n') continue; char s2[20];//s2 would be aaa cin.getline(s2,20); int c=strlen(s2); char *q=strstr(arr,s2);// im searching for string 2 in the array while(q!=NULL){ if (c<5){// if string length is less than 5 for(int i=strlen(arr);i>arr[q+(c-1)];i--)// i just need away to let the pointer tell me its position in the array arr[i+(5-c)]=arr; for(int j=q;j<6;j++) arr[j]='*'; } else if(c>5){ for(int i=q+4;i<strlen(arr);i++) arr=arr[i+(c-5)]; for(int j=q;j<6;j++) arr[j]='*'; } else if(c=5){ for(int j=q;j<6;j++) arr[j]='*'; } q=strstr(arr,s2); } cout<<arr<<endl; } any ideas will be helpfull.