Ok first Question:
How to pass an array of 20 pointers, pointing to a strucutre (I think that is what I have declared). Would like to know what would be written in the function prototype and the function definition header
Second Question
I see that I have declared array of 20 pointers, each pointing to the structure I created. Now is it possible I use just one pointer which points to an Structure array of say 20.
Third Question
Which way is better. Basically what I am thinking is declaring an array of 20 pointers to the contact, i am not really using up much memory but if I declare an structure array of 20 I would be declaring memory, and then if I use a pointer to point to it, it wouldn't be pretty much foo. But thats just what I am thinking
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
struct contact
{
char firstName[20];
char lastName[20];
char phoneNum[20];
char emailAdd[80];
};
void getInput(contact *, ifstream);
int main(void)
{
contact *myContacts[5]; //I am not sure whether this is the correcet way
ifstream fin;
ofstream fout;
getInput(myContacts, fin)
}
void getInput(contact *myContacts, ifstream fin)
{
fin.open("file.txt");
for(int i = 0; fin.eof(); i++)
{
myContacts[i]->firstName;
myContacts[i]->lastName;
myContacts[i]->phoneNum;
myContacts[i]->emailAdd;
}
}

New Topic/Question
Reply




MultiQuote







|