Skip to content

Instantly share code, notes, and snippets.

@SeanPlusPlus
Created April 10, 2017 16:29
Show Gist options
  • Save SeanPlusPlus/f9f98f2517949c89c49a17f03746e04c to your computer and use it in GitHub Desktop.
Save SeanPlusPlus/f9f98f2517949c89c49a17f03746e04c to your computer and use it in GitHub Desktop.
first program I ever wrote professionally
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream input_file_counter("input_file.txt");
int temp;
int NUMBER_OF_DOCUMENTS = 0;
while ( input_file_counter >> temp )
{
NUMBER_OF_DOCUMENTS++;
}
ifstream input_file("input_file.txt");
ofstream output_file;
output_file.open("output_file.txt");
int * document;
document = new int [NUMBER_OF_DOCUMENTS];
int i, x;
for(i = 0; i < NUMBER_OF_DOCUMENTS; i++)
{
input_file >> document[i];
output_file << ",Y,,," << document[i] << endl;
for(x = 1; x < document[i]; x++)
output_file << ",,,," << endl;
}
output_file.close();
input_file.close();
delete [] document;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment