Thread: Help me finding the errors PLEASE !!!

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    5

    Post Help me finding the errors PLEASE !!!

    HELLOW EVERY BODY

    This is my program and I can't find the errors

    waiting for your coments




    Code:
    # include <iostream>
    # include <string>
    # include <fstream>
    # include <iomanip>
    
    using namespace std ;
    
    struct patient
    {
    string fname;
    int id;
    int age;
    };
    
    void Read (patient [],int&);
    void Find (patient [],int,int&);
    void Display (patient [],int&);
    
    int main()
    {
    patient info[20];
    int num(0),x(0);
     
    Read(info,x);
    Find(info,x,num);
    cout<<"Number of patints in twenties = "<< num;
    Display(info,x);
    return 0;
    }
    
    
    void Read (patient info[],int x)
    {
    ifstream din;
    din.open("data.dat");
    int c(0);
    
    while (din)
    {
    din>>info[c].fname>>info[c].id>>info[c].age;
    c++;
    }
    
    }
    
    
    void Find (patient info[],int x, int&num)
    {
    int c(0);
    
    while (c<20)
    {
    if (info[c].age>20 && info[c].age<29)
    num++;
    c++;
    }
    
    }
    
    void Display (patient info[],int x)
    {
    int c(0);
    cout <<" Patint name ID";
    
    while (c<20)
    {
    if (info[c].age>20 && info[c].age<29)
    cout<<setw(12)<<info[c].fname<<setw(12)<<info[c].id;
    c++;
    }
    
    }
    Last edited by Salmi; 01-10-2010 at 12:24 PM.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Error #1: indentation sucks

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    5
    I forgot to say that I am using visual stude 2005 C++

  4. #4
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    [Linker error] undefined reference to `Read(patient*, int&)'
    [Linker error] undefined reference to `Display(patient*, int&)'
    ld returned 1 exit status
    4 errors found.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    19
    Theres something wrong with your function declarations.

    I moved the main() to the end of the file and removed the

    Code:
    void Read (patient [],int&);
    void Find (patient [],int,int&);
    void Display (patient [],int&);
    and the code compiled ok.

    Edit: Just removing the "x" (which you aren't using anyway) from all arguments solves the problem.

    Edit again: Solved it. You forgot to put & at the appropriate places in your definitions. I.e:

    Code:
    void Read (patient info[],int& x)
    {
    and

    Code:
    void Display (patient info[],int& x)
    {
    int c(0);
    Last edited by Walle; 01-10-2010 at 01:41 PM.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    5
    THANK YOU VERY MUCH

    I have found the errors

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. errors using my parser- MSVC++ 6, bhtypes.h
    By AeroHammer in forum C++ Programming
    Replies: 6
    Last Post: 01-25-2005, 07:11 PM
  2. MFC :: Finding Child Window of a CWnd* Object?
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2003, 09:06 AM
  3. opengl Nehe tutorial errors when compiling
    By gell10 in forum Game Programming
    Replies: 4
    Last Post: 07-14-2003, 08:09 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM