Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

image text in transcribed

#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:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

4. What are the current trends in computer software platforms?

Answered: 1 week ago