Created
April 29, 2017 18:41
-
-
Save pablocortez/28c2b61f724d8e149cb5b89e0d9d29f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
string names[10]; | |
long long numbers[10]; | |
int namesLength = (sizeof(names) / sizeof(*names)); | |
int numbersLength = (sizeof(numbers) / sizeof(*numbers)); | |
int readNames() | |
{ | |
ifstream File("TelephoneNames.txt"); | |
int i = 0; | |
while(!File.eof()) | |
{ | |
File >> names[i]; // get data from file and populate onto array | |
i++; | |
} | |
File.close(); | |
// cout << "\nNames: " << endl; | |
// for (int x = 0; x < namesLength; x++) | |
// { | |
// if (names[x] != "") | |
// cout << "........ " << names[x] << endl; | |
// } | |
} | |
int readNumbers() | |
{ | |
ifstream File("TelephoneNumbers.txt"); | |
int i = 0; | |
while(!File.eof()) | |
{ | |
File >> numbers[i]; | |
i++; | |
} | |
File.close(); | |
// cout << "\nPhone Numbers: " << endl; | |
// for (int x = 0; x < numbersLength; x++) | |
// { | |
// if(names[x] != "") | |
// cout << "........ " << numbers[x] << endl; | |
// } | |
} | |
int displayRecords() | |
{ | |
cout << "\nPhone Numbers: " << endl; | |
for (int x = 0; x < numbersLength; x++) | |
{ | |
if(names[x] != "") | |
cout << names[x] << " ........ " << numbers[x] << endl; | |
} | |
} | |
int main() | |
{ | |
readNames(); | |
readNumbers(); | |
displayRecords(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment