Thread: header file problems

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    134

    header file problems

    I found this code for pig latin, and the thing is that the scanner.h header file is giving me problem, there is also a c version of the header file....can anyone help me out how to use it, the other header files work fine.
    I am attaching the files so you;ll can have a look, thanks

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    here is the other file, the header file
    i am attaching the .c file as well
    Code:
    /*
     * File: scanner.h
     * ---------------
     * This file is the interface to a package that divides
     * a line into individual "tokens".  A token is defined
     * to be either
     *
     * 1. a string of consecutive letters and digits representing
     *    a word, or
     *
     * 2. a one-character string representing a separator
     *    character, such as a space or a punctuation mark.
     *
     * To use this package, you must first call
     *
     *        InitScanner(line);
     *
     * where line is the string (typically a line returned by
     * GetLine) that is to be divided into tokens.  To retrieve
     * each token in turn, you call
     *
     *        token = GetNextToken();
     *
     * When the last token has been read, the predicate function
     * AtEndOfLine returns TRUE, so that the loop structure
     *
     *        while (!AtEndOfLine()) {
     *            token = GetNextToken();
     *            . . . process the token . . .
     *        }
     *
     * serves as an idiom for processing each token on the line.
     *
     * Further details for each function are given in the
     * individual descriptions below.
     */
    
    #ifndef _scanner_h
    #define _scanner_h
    
    #include "genlib.h"
    
    /*
     * Function: InitScanner
     * Usage: InitScanner(line);
     * -------------------------
     * This function initializes the scanner and sets it up so that
     * it reads tokens from line.  After InitScanner has been called,
     * the first call to GetNextToken will return the first token
     * on the line, the next call will return the second token,
     * and so on.
     */
    
    void InitScanner(string line);
    
    /*
     * Function: GetNextToken
     * Usage: word = GetNextToken();
     * -----------------------------
     * This function returns the next token on the line.
     */
    
    string GetNextToken(void);
    
    /*
     * Function: AtEndOfLine
     * Usage: if (AtEndOfLine()) . . .
     * -------------------------------
     * This function returns TRUE when the scanner has reached
     * the end of the line.
     */
    
    bool AtEndOfLine(void);
    
    #endif

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    So, is it C or C++?

    I see string and bool, both of which are C++ by default, but I suppose you could typedef them into C.

    Anyway:
    >>the scanner.h header file is giving me problem,<<
    What does that mean? Care to expand.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    well the all the header files are found by the compiler. But when i build the .exe file, the scanner file gives some errors, how do i fix them????
    these are the errors that i get during building the .exe

    --------------------Configuration: piglatin - Win32 Debug--------------------
    Linking...
    piglatin.obj : error LNK2001: unresolved external symbol _GetLine
    piglatin.obj : error LNK2001: unresolved external symbol _GetNextToken
    piglatin.obj : error LNK2001: unresolved external symbol _AtEndOfLine
    piglatin.obj : error LNK2001: unresolved external symbol _InitScanner
    piglatin.obj : error LNK2001: unresolved external symbol _IthChar
    piglatin.obj : error LNK2001: unresolved external symbol _StringLength
    piglatin.obj : error LNK2001: unresolved external symbol _SubString
    piglatin.obj : error LNK2001: unresolved external symbol _Concat
    Debug/piglatin.exe : fatal error LNK1120: 8 unresolved externals
    Error executing link.exe.

    piglatin.exe - 9 error(s), 0 warning(s)

  5. #5
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    I don't have the embedded includes in your file, but unresolved externals usually mean that the function definition(s) is / are missing or a required library isn't being linked in.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    the other files you can google them, and you can download them

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Do you actually have the source for those "missing functions"?
    Are they in multiple source files?
    Are you compiling/linking them together?
    If you're using MSVC, have you created a project and put all these files into it? (which would hopefully link them all together nicely).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    how do i link them in microsoft vis ++

    after all i am a noob

  9. #9
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Well, I don't have msvc myself, but last time I did use it, you had to create a project, and add all your .c and .h files to it. Then hit compile.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  10. #10
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    In VC6

    create a new empty project (I used console app)
    create a new c++ source file and save it as main.c or whatever.
    Code:
    /* main.c */
    #include <stdio.h>
    #include "fullpath\test.c"
    
    int main()
    {
         showChar('A');
         showChar('\n');
         return 0;
    }
    Code:
    /* test.c */
    #include <stdio.h>
    
    void showChar(char in)
    {
         putchar(in);
    }
    Something like that. Or just use the add to project check box and copy and paste the files into newly created replacements
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM