MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / Solution

Class Solution

C++/Defanging an IP Address.cpp:8–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7#include<bits/stdc++.h>
8class Solution {
9public:
10 string defangIPaddr(string address) {
11 string op;
12//A for loop which will execute till the address[i] which means the string runs till the last character of the string is Null
13 for(int i=0;address[i]!='\0';i++)
14 {
15 //if address[i]== '.' which means that if the in a string contains a period we'll replace it with [.]
16 if(address[i]=='.')
17 {
18 //This line adds the square brackets if there's a period in a string
19 op=op+'['+ address[i]+']';
20 i++;
21
22 }
23 op=op+address[i];
24
25 }
26 return op;
27 }
28};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected