ADT Won't Work?

This is a discussion on ADT Won't Work? within the C++ Programming forums, part of the General Programming Boards category; Im at the begining of making my program and i can't get my program to run. I have created the ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    13

    ADT Won't Work?

    Im at the begining of making my program and i can't get my program to run.

    I have created the following files:

    Job Agency.cpp
    applicant.cpp
    applicant.h

    At the moment I am trying to get the users input and save it into stdin using structures and data types but everytime I go to run the program the following error message appears.

    [LinkerError] Unresolved external 'ApplicantInput(std::FILE*,Applicant*)' referenced from C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\UNI\2003\ALGORITHMS & DATA STRUCTURES\ASSIGNMENTS\ASSIGNMENT1.OBJ.

    Could someone please have a look at my files and tell me what I am doing wrong.

    Thanks,
    Attached Files Attached Files
    Last edited by sunkloto05; 08-31-2003 at 11:18 PM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    13
    applicant implementation:
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    13
    header file
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    13
    Please, Can anyone try and help me as this is my first attempt at using Abstract Data Types and I am stuck.

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Don't bump, you're less likely to get an answer that way.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    13
    ok sorry for that. It's just that I really want to work this out and no ones helping.

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Your problem is most likely this:

    Code:
    //prototype
    bool ApplicantInput (FILE *, Applicant *);
    //definition
    bool ApplicantInput (FILE * fp, Applicant * a, Applicant * b)
    {
    The parameters should match up, unless you're overloading, which you're not.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    13
    in applicant.cpp I changed it to

    Code:
    bool ApplicantInput (FILE * fp, Applicant * a, Applicant * b)
    but now the error message

    [C++Error] Assignment1.cpp(84): Too few parameters in call to 'ApplicantInput(std::FILE *,Applicant *,Applicant *)'.

    is showing.

  9. #9
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Did you change the function call (which, I assume, is in main) to match?
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  10. #10
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Ooops didn't see that one. Yeah, that's probably the problem.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  11. #11
    Registered User
    Join Date
    Aug 2003
    Posts
    13
    Thanks for your help. I have got it to read in a but I need it to read in b.

    here is the code

    jobagency.cpp
    Code:
                        Applicant * a, * b;
    
                        a = ApplicantConstruct();
                        printf("Enter Name: ");
                        ApplicantInput(stdin, a, b);
    applicant.cpp
    Code:
                     bool ApplicantInput (FILE * fp, Applicant * a, Applicant * b)
    {
        return scanf ("%s %s", &a->name, b->address) == 2;
    }
    it reads in Enter Name: but I also need it to read in Enter Address

  12. #12
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    return scanf ("%s %s", &a->name, b->address) == 2;
    1. Why have you put "== 2" there?

    2. Maybe you need to separate each %s with a \n ( enter key):
    Code:
    return scanf ("%s\n%s", &a->name, b->address);
    I hope that helps.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  13. #13
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Why have you put "== 2" there?
    2 is the correct return code for that call to scanf().

    But, why are you using scanf() in the first place? If you're doing this in C++, use cin or getline (and open the file with C++ fstreams), for a C solution use fgets().
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 11:50 AM
  2. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 11:39 PM
  3. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 09:37 AM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21