Thread: "unresolved external error"

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    14

    "unresolved external error"

    please help!! , just compile and see errors , this is for converting to octal,hex, and regular

    Code:
    /* Include Files */
    #include <stdio.h>
     
    /* Constant Declarations */
    #define TRUE  1
    #define FALSE 0
     
    /* Function Prototypes */
    char get_char_and_clear( void );
    char get_quit_char_and_clear( void );
    void display( int, char, char );
    void distinguish( int, char );
     
    int main( void )
    {
        int number;
        char inbase, outbase, quit = 'A';
     
        printf( "INTEGER CONVERSION PROGRAM\n" );
        printf( "--------------------------\n\n" );
     
        /* while loop will input and convert one number */
        while ( quit != 'n' && quit != 'N' )  {
           printf( "Base of input (d=decimal, h=hexadecimal, o=octal): " );
           inbase = get_char_and_clear();
     
           printf( "Number: " );
           if (inbase == 'd' )
               scanf( "%d", &number );
           else if ( inbase == 'h' )
               scanf( "%x", &number );
           else if ( inbase == 'o' )
               scanf( "%o", &number );
     
           printf( "Base of output (d=decimal, h=hexadecimal, o=octal): " );
           outbase = get_char_and_clear();
     
           display( number, inbase, outbase );
     
           printf( "Another number? (Y/N) " );
           quit = get_quit_char_and_clear();
        }
        return 0;
    }

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Looks like you need to review functions again. It is not enough to just type out prototypes. The functions need to be completely defined.

    Also if you're smart enough to title this thread "unresolved external errors", I think you're smart enough to actually show the errors in the post. It is going to be frustrating when you have a more complicated error next time, and the only thing you're used to saying is "compile [it yourself] and see errors". It's only because this is an easy error to see that I'm helping you.

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    14
    thanks i am just really tired completely spaced my mind to define them XD, for those who are interested in the correct code here it is:

    Code:
    /*  
     *
     *  Converts an input integer to another base. The
     *  input and/or the output can be in decimal, octal
     *  or hexadecimal.
     */
     
    /* Include Files */
    #include <stdio.h>
     
    /* Constant Declarations */
    #define TRUE  1
    #define FALSE 0
     
    /* Function Prototypes */
    char get_char_and_clear( void );
    char get_quit_char_and_clear( void );
    void display( int, char, char );
    void distinguish( int, char );
     
    int main( void )
    {
        int number;
        char inbase, outbase, quit = 'A';
     
        printf( "INTEGER CONVERSION PROGRAM\n" );
        printf( "--------------------------\n\n" );
     
        /* while loop will input and convert one number */
        while ( quit != 'n' && quit != 'N' )  {
           printf( "Base of input (d=decimal, h=hexadecimal, o=octal): " );
           inbase = get_char_and_clear();
     
           printf( "Number: " );
           if (inbase == 'd' )
               scanf( "%d", &number );
           else if ( inbase == 'h' )
               scanf( "%x", &number );
           else if ( inbase == 'o' )
               scanf( "%o", &number );
     
           printf( "Base of output (d=decimal, h=hexadecimal, o=octal): " );
           outbase = get_char_and_clear();
     
           display( number, inbase, outbase );
     
           printf( "Another number? (Y/N) " );
           quit = get_quit_char_and_clear();
        }
        return 0;
    }
     
    /*  Function: get_char_and_clear()
     *
     *  Gets either a 'd', a 'h', or an 'o', from the user.
     *  and clears extraneous characters and the newline
     *  from the input buffer.
     */ 
     
    char get_char_and_clear( void )
    {
        int inchar;
     
        while ( ((inchar = getchar()) != 'd') && (inchar != 'h') && (inchar != 'o') )
        ;
     
        while ( getchar()  != '\n' )
        ;
     
        return (char) inchar;
    }
     
    /*  Function: get_quit_char_and_clear()
     *
     *  Gets any non-white character from the user.
     *  and clears extraneous characters and the newline
     *  from the input buffer.
     */ 
     
    char get_quit_char_and_clear()
    {
        int inchar;
     
        while ( (inchar = getchar()) == ' ' || inchar == '\t' && inchar != '\n' )
        ;
     
        while ( getchar() != '\n' )
        ;
     
        return (char)inchar;
    }
     
     
     
     
    /*  Function: display()
     *  displays the original number and the converted result
     */
     
    void display( int num, char in, char out )
    {
        printf( "The number" );
     
        distinguish( num, in );
     
        printf( " is" );
     
        distinguish ( num, out );
        printf( ".\n" );
    }
     
    /*  Function: distinguish()
     *
     *  Looks at base and displays num in the correct base
     */
     
    void distinguish( int num, char base )
    {
        if ( base == 'd' )
           printf( " %d in decimal", num );
        else if ( base == 'h' )
           printf( " %x in hexadecimal", num );
        else if ( base == 'o' )
           printf( " %o in octal", num );
    }

  4. #4
    Registered User
    Join Date
    Mar 2012
    Posts
    14
    i have a head ache

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "error LNK2001: unresolved external symbol"problem
    By gjgcstick in forum C++ Programming
    Replies: 2
    Last Post: 03-05-2010, 09:06 AM
  2. Replies: 6
    Last Post: 08-26-2008, 12:38 PM
  3. "Unresolved External Symbol" Error
    By mikeman118 in forum C++ Programming
    Replies: 12
    Last Post: 12-20-2007, 10:05 AM
  4. Replies: 8
    Last Post: 04-27-2006, 10:39 AM
  5. Ask about these "unresolved external symbol" error
    By ooosawaddee3 in forum C++ Programming
    Replies: 1
    Last Post: 06-29-2002, 11:39 AM