Theres an error on The bolded line, what am I doing wrong?
#include <iostream>
//just for writing and reading from console
#include <fstream>
//this one to deal with files, read and write to text files
using namespace std;
int main()
{
//first thing we need to read the data in the text file
//let's assume we have the reading in a text file called
data.txt
//so, we need a stream input variable to hold this data
ifstream infile;
//now we copy the data from the file into this variable
infile.open("data.txt");
//now we have the text copied to this stream
//first thing we need to check if the file is open or not
if(!infile.eof())
//
{
cout<<"Error opening the file.";
return -1; //this line will end the program
}
//here we need to open the file that we will print
//the output to, that is the encrypted file
ofstream outfile;
outfile.open("out.txt"); //this will create an out file to write in
later
//here we need to make a loop to change each character in the
file
string line; //this will hold the string in each line in the
infile
while(outfile.getline(line)) //this statement copies
data
{
//here we make the encryption on the line, and then print it back
into
//the output file
for(int i=0;i<line.length();i++)
{
line[i] += 3;
}
//now the line has been encrypted
//we pass it to the out file
outfile<<line<<endl; //just copy the line there and
make a new line
}
//now we close both files
infile.close();
outfile.close();
}
#include <iostream> //just for writing and reading from console #include <fstream> #include <string> //this one to deal with files, read and write to text files using namespace std; int main() { //first thing we need to read the data in the text file //let's assume we have the reading in a text file called data.txt //so, we need a stream input variable to hold this data ifstream infile; //now we copy the data from the file into this variable infile.open("data.txt"); //now we have the text copied to this stream //first thing we need to check if the file is open or not if (!infile.eof()) // { cout << "Error opening the file."; return -1; //this line will end the program } //here we need to open the file that we will print //the output to, that is the encrypted file ofstream outfile; outfile.open("out.txt"); //this will create an out file to write in later //here we need to make a loop to change each character in the file string line; //this will hold the string in each line in the infile while (getline(infile, line)) //this statement copies data { //here we make the encryption on the line, and then print it back into //the output file for (int i = 0; i < line.length(); i++) { line[i] += 3; } //now the line has been encrypted //we pass it to the out file outfile << line << endl; //just copy the line there and make a new line } //now we close both files infile.close(); outfile.close(); }
Theres an error on The bolded line, what am I doing wrong? #include <iostream> //just for...
I need help debugging this C++ prgram. What Am i doing wrong? //******************************************************** // This program reads two input files whose lines are //ordered by a key data field. This program should merge //these two files, writing an output file that contains //all lines from both files ordered by the same key field. // //********************************************************* #include <iostream> #include<string> #include<fstream> //prototype void mergeTwoFiles (ifstream&,ifstream&, ofstream&); using namespace std; int main() {string inFile1,inFile2,outFile; // input and output files ifstream in1; ifstream in2;...
Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; //function void displaymenu1(); int main ( int argc, char** argv ) { string filename; string character; string enter; int menu1=4; char repeat; // = 'Y' / 'N'; string fname; string fName; string lname; string Lname; string number; string Number; string ch; string Displayall; string line; string search; string found; string document[1000][6]; ifstream infile; char s[1000];...
I am getting an error that the variable num was not declared in the scope on the line of code that has; while(num != 5). Do you know how to fixe this error? #include <iostream> #include <iomanip> #include <string> #include<fstream> #include <cstring> using namespace std; //Declare the structure struct Games { string visit_team; int home_score; int visit_score; }; // Function prototypes int readData(Games *&stats); int menu(); void pickGame(Games *&stats, int size); void inputValid (Games *&stats, int size); void homeTotal(Games *&stats,...
I am using python3.6 and i am getting an error on line 42 num = int(fin.readline()) #reading first value valueError: invalid literal, for int() with base 10 Any help is appreciated, here is the code. reads from txt file a few integers in an array and sorts them. thank you! # Function to do insertion sort def insertionSort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] # Move elements of...
I have the files set up in the write place. I am just confused on how to use some of the desire methods to execute this code. // Copy text file and insert line numbers Create a NetBeans project named AddLineNumbers following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans project AddLineNumbers and before you attempt to execute your application download and/or copy the text...
What am I doing wrong on this? Chapter 17, Problem 3E // Michael Cole // 6/28/2017 // Name spaces for application using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Week8 { public partial class Form1: Form { // Get the location where the data file would be created string fileLoc = Application.StartupPath + "\\Datafile.txt"; /* Constructor of the class to create the GUI of the form */ public Form1() ...
Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13 +...
Instructions: Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13...
nothing happens when I replace the skeleton code. the program runs but it does not give me the desired results. All the question marks must be removed and filled in with the appropriate code.// Function prototypesvoid displayAllLines(ifstream &infile);void displayLastLine(ifstream &infile);int main(){// Arrays for file nameschar fileName1[SIZE];char fileName2[SIZE];// File stream objectsifstream jokeFile;ifstream punchlineFile;// Explain the program to the user.cout << "This program will print a joke "<< "and its punch line.\n\n";// Get the joke file name.cout << "Enter the name of...
moviestruct.cpp #include <iostream> #include <fstream> #include <cstdlib> #include <ostream> #include <fstream> #include <cstdlib> #include <cstring> using namespace std; typedef struct{ int id; char title[250]; int year; char rating[6]; int totalCopies; int rentedCopies; }movie; int loadData(ifstream &infile, movie movies[]); void printAll(movie movies[], int count); void printRated(movie movies[], int count); void printTitled(movie movies[], int count); void addMovie(movie movies[],int &count); void returnMovie(movie movies[],int count); void rentMovie(movie movies[],int count); void saveToFile(movie movies[], int count, char *filename); void printMovie(movie &m); int find(movie movies[], int...