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.

There's no hope for that code. Start over, this time paying close attention to a good C++ reference.

No Hope?!!! That sounds bad, I thought I was on the right track. Thanks for your time and comments

>I thought I was on the right track
Logically, yes. Syntactically, not even close. Most of your lines contain a syntactic or semantic error. I highly recommend writing as little as possible and then compiling, adding as little as possible and then compiling. Repeat the process until you've incrementally built a program that actually compiles. And unless you're comfortable with the language you're working with, keep a reference with you at all times and check it religiously.

Thanks again for the advice!! My new best friend is a c++ book I bought today!

another thing you might want to do is comment your code, I find this incredibly usefull when im working on anything bigger then a hello world.

youshould have a

using namespace std;

to define your namespace this will clear up about half your errors if not more.

i am getting an error about clrscr() not being defined? and at the end the compiler is thinking the last clrscr() is a function declaration. and not a function call. ( maybe an extra bracket im not seeing?)

>to define your namespace this will clear up about half your errors if not more
No, it will cause more. Since the OP is using the pre-standard iostream.h header, namespaces can't be used.

>i am getting an error about clrscr() not being defined?
Your compiler doesn't support it, but that doesn't say anything about the OP's compiler.

I'm beginning to feel like i jumped in the c++ deep end. Commenting my code was good advice, I can see more clearly now where i'm supposed to be heading. Thanks

>I'm beginning to feel like i jumped in the c++ deep end.
There is no shallow end to C++, no worries. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.