forked from tanus786/CP-Codes-HackOctober-Fest-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tanus786#747 from SonuKushwaha-hub/patch-6
Create Character Stuffing
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
int main() | ||
{ | ||
char so[100],data[100]; | ||
cout<<"Enter the text: "; | ||
cin>>so; | ||
char flag,bit; | ||
cout<<"enter the flag: "; | ||
cin>>flag; | ||
cout<<"enter the character: "; | ||
cin>>bit; | ||
|
||
int size=strlen(so); | ||
data[0]=flag; | ||
int i,j; | ||
for(i=0,j=1;i<size;i++) | ||
{ | ||
if(so[i]==bit) | ||
{ | ||
data[j]=so[i]; | ||
j++; | ||
data[j]='k'; | ||
j++; | ||
|
||
} | ||
else{ | ||
data[j]=so[i]; | ||
j++; | ||
} | ||
} | ||
data[j]=flag; | ||
data[j+1]='\0'; | ||
cout<<data; | ||
return 0; | ||
} |