Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created February 22, 2021 06:19
Show Gist options
  • Save amankharwal/11cf90a52c01e903105ef43596438d52 to your computer and use it in GitHub Desktop.
Save amankharwal/11cf90a52c01e903105ef43596438d52 to your computer and use it in GitHub Desktop.
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
string DefangIP(string str)
{
string defangIP = "";
for (char c : str)
(c == '.') ? defangIP += "[.]" :
defangIP += c;
return defangIP;
}
int main()
{
string str;
cin>>str;
cout <<DefangIP(str);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment