C++ Program to Defang IP Address Full Project For Beginners

  • Post author:
  • Post category:c++
  • Post comments:0 Comments

 

 

main.cpp

 

 

// C++ implementation to find the
// defanged version of the IP address

#include <bits/stdc++.h>

using namespace std;

// Function to generate a
// defanged version of IP address.
string GeberateDefangIP(string str)
{
	string defangIP = "";
	
	// Loop to iterate over the
	// characters of the string
	for (char c : str)
		(c == '.') ? defangIP += "[.]" :
					defangIP += c;
	return defangIP;
}

// Driven Code
int main()
{
	string str = "255.100.50.0";
	cout << GeberateDefangIP(str);
	return 0;
}

Leave a Reply