Skip to content

Instantly share code, notes, and snippets.

@SeqviriouM
Created September 30, 2013 17:16
Show Gist options
  • Save SeqviriouM/6767033 to your computer and use it in GitHub Desktop.
Save SeqviriouM/6767033 to your computer and use it in GitHub Desktop.
Task3
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string str,str1,str2,dopstr;
int count,i,j,k,pos,pos1,pos2;
ifstream fin;
ofstream fout;
fin.open("input.txt");
fout.open("output.txt");
while(getline(fin,str))
{
if (str.find("host") == 0)
{
pos1 = 6;
while(str[pos1] == ' ')
{
pos1++;
}
pos2=pos1;
while(str[pos2] != ' ')
{
pos2++;
}
pos = str.find(" dns");
str.erase(pos+1 ,4);
str = str.substr(0,pos1) + "dns "+str.substr(pos1);
}
fout<<str<<endl;
}
fout.close();
fin.close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment