Defanged Version of Internet Protocol Address | C ++ implementation to find the defanged version of the IP address ; Function to generate a defanged version of IP address . ; Loop to iterate over the characters of the string ; Driven Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string GeberateDefangIP ( string str ) { string defangIP = " " ; for ( char c : str ) ( c == ' . ' ) ? defangIP += " [ . ] " : defangIP += c ; return defangIP ; } int main ( ) { string str = "255.100.50.0" ; cout << GeberateDefangIP ( str ) ; return 0 ; }