So I need to create a program that opens a text file and reads the content and then create an array. I also need to create an array that uses the same text file but looks for lines that begin with the same number. I don't know where to begin with looking for duplicates. I need to output the new array (the one without duplicates) into another file. Below is what I have so far.
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <algorithm>
usingnamespace std;
void createarray();
//Function for array creation "createarray"
void createarray ()
{
string pirates[5];
// creates array to hold names
short loop;
//short for loop for input
short loop2;
//short for loop for output
string line[100];
//this will contain the data read from the file
ifstream myfile ("input.txt");
//opening the file.
if (myfile.is_open()) //if the file is open
{
while (! myfile.eof() ) //while the end of file is NOT reached
{
getline (myfile,line[100]);
cout << line[100] << endl; //and output it
int line [100]; //criteria for input loop (as array 0-5)
}
}
}
void checkdup ()
{
ifstream myfile.open("input.txt");
}
int main()
{
cout <<"Here is the raw data for the votes, these include any duplicates."<<endl;
createarray();
cout << "Here is the file without duplicates"<<endl;
}
Why delete the other thread? There are answers in it already, so even if you deleted your post, you would leave meaningless answers there. Why not simply update that one with a new post?
Spamming the forum with multiple threads wastes your time and ours, because you end up with different people trying to help you in different threads.
Akroncs, I think we may be working on the same type of project here. Have you gotten any farther along? I am literally right before what you have posted here. Thanks.