I've read some of your thoughts on student postings and while I am keen to do things on my own behalf I have hit a wall. I've slaved at this project, mainly because I've not done any programming before, but i can't get my code to run and can't seem to see why.
Any help would be much appreciated.
Purps xx
Also is there a rule on how to post code?
<< moderator edit: added [code][/code] tags >>
#include <iostream.h>
#include <cstring.h>
#include <conio.h>
struct contact{
string name;
string number;
};
void main(){
struct contact *entry;
int i,number;
string namesearch;
char c;
cout<<"How many entrys? ";
cin>>number;
cin.get(c);
entry = new struct contact[number];
for(i=1;i<number;i++){
cout<<"Name ";
getline(cin, entry[i].name);
cout<<"Phone number ";
cin>>entry[i].number;
cin.get(c);
};
clrscr();
for (i=1;i<number;i++);
cout<<entry[i].name<<" "<<entry[i].number<<endl;
cout<<"Search for a contact: "<<endl;
cout<<"(Press Z to stop) Contact Name: ";
cin.getline(namesearch);
while (char(namesearch, "Z")<0);{
clrscr();
string(entry[0].name = namesearch);
i = number;
while (string(entry[i].name = namesearch) !=0)
i--;
if (i==0)
cout<<"Not available"<<endl;
cout<<"Press enter to search again";
cin.get(c);
}
else
{
cout<<"Conatact Name: "<<entry[i].name<<endl;
cout<<"Phone Number: "<<entry[i].number<<endl;
cout<<"Press enter to search again";
cin.get(c);
}
clrscr();
cout<<"Search for a contact "<<endl;
cout<<"(Press Z to stop) Contact Name: "<<endl;
cin.getline(namesearch);
}
Code reformatted. -Narue
Thanks again for your time.