the program should be able to read "input.txt"
ifstream infile("input.txt")
output on the picture below. please fix or create a new code
#include #include #include #include using namespace std; int main() { string input; //To store user input string str; int ind1,ind2,temp; map virus; //maps virus id with virus data map ::iterator it; //To traverse map of virus stringstream ss; ifstream file; string filename; int ind,prev; filename = "input.txt"; //File name file.open(input); // open file while(getline(file,input)) { if(input[0]=='V') //virus { ind1 = input.find(" "); ind2 = input.find(":",ind1+1); //Everything in between index1 and index2 will contains virus ID str = input.substr(ind1+1,ind2-ind1-1); //str will contain virus ID in string format //convert virus ID from string to integer ss>temp; ss.clear(); str = input.substr(ind2+2); //str will contain virus size and data //Trim virus size and extract only virus data ind1 = str.find(" "); str = str.substr(ind1+1); //str will contain virus data virus.insert(make_pair(temp,str)); } else //file { ind1 = input.find(" "); ind2 = input.find(":",ind1+1); //Everything in between index1 and index2 will contains file ID str = input.substr(ind1+1,ind2-ind1-1); //str will contain virus ID in string format //convert file ID from string to integer ss>temp; ss.clear(); str = input.substr(ind2+2); //str will contain virus data //Trim file size and extract only file data ind1 = str.find(" "); str = str.substr(ind1+1); //str will contain file data it = virus.begin(); { while(it!=virus.end()) //Traverse complete map { if(str.find(it->second)!=-1) //File contains this virus break; it++; } } if(it==virus.end()) //File contains no virus { coutfirst; } cout - Create a C++ program that checks whether a file(from a set of files) is infected by computer viruses. To do this, one needs to check whether a file contains a virus signature. The database of virus signatures is given as input. Rules: -The input consists of one or more lines of virus signatures followed by one or more lines of file data. Each virus is identified by a unique nuber. The virus signature data format is as follow: VIRUS n: k: