Skip to content

Instantly share code, notes, and snippets.

@amankharwal

amankharwal/defang.cpp Secret

Created Feb 22, 2021
Embed
What would you like to do?
#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