Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code Below is in C++. Please give some vulnerabilities present in the code given below. Also, if you could give some that include string manipulation

Code Below is in C++.

Please give some vulnerabilities present in the code given below. Also, if you could give some that include string manipulation errors, that would be greatly appreciated. Thanks.

#include

#include

#include

#include

using namespace std;

void stringReverse(string & str) {

int n = str.length();

for(int i = 0; i < n / 2; i++)

swap(str[i], str[n - i - 1]);

}

int main() {

.

ofstream outfile;

string data;.

cout << "Please enter a string" << endl;

getline(cin, data);

outfile.open("CSC450_CT5_mod5.txt", std::ios_base::app);

outfile << data << endl;

ofstream outfile2("CSC450_CT5_mod5_reversed.txt");

ifstream infile("CSC450_CT5_mod5.txt");

while(infile) {

getline(infile, data);

stringReverse(data);

outfile2 << data << endl;

}

return 0;

}

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

Students also viewed these Databases questions