//
// main.cpp
// 3. CPPTutorialA Slides 8-11
//
// Created by Adam Thoseby on 09/09/2012.
// Copyright (c) 2012 Adam Thoseby. All rights reserved.
//
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
usingnamespace std;
int fDetails(string arrayTokens[]);
int main(int argc, constchar * argv[])
{
string arrayTokens[2];
int nTokens;
string * pStart, * pFinish;
nTokens = fDetails(arrayTokens);
for (int i=0; i<nTokens; i++) {
cout<<arrayTokens[i]<<endl;
}
pStart = &arrayTokens[0];
pFinish = &arrayTokens[nTokens];
cout<<pStart<<endl<<pFinish;
return 0;
}
int fDetails (string arrayTokens[]){
int nTokens = 0, i = 0;
string fname, number;
//cout<<"Please enter in the address, file name and the extension so we can open the file: "<<endl;
//cin>>fname;
fname="/Users/ANCT/Desktop/num.txt";
ifstream fin;
fin.open(fname.c_str());
if (!fin) {
cout<<"\nPlease ensure that the file is located in the default directory.\nAlso please ensure that the file is spelt correctly, including the extension.\n"<<endl;
return 0;
}
while (!fin.eof()) {
i++;
fin>>number;
}
fin.close();
fin.open(fname.c_str());
arrayTokens = new string[i];
for (int n=0; n<i; n++) {
getline(fin,arrayTokens[n]);
}
nTokens = i;
return nTokens;
}