Compile Error:

This is a discussion on Compile Error: within the C Programming forums, part of the General Programming Boards category; here's my compile error. Code: $ cc fig07_10.c /tmp/cc5AugyJ.o: In function `main': fig07_10.c:(.text+0x69): undefined reference to `convertToUpperCase' collect2: ld returned ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    182

    Compile Error:

    here's my compile error.
    Code:
    $ cc fig07_10.c
    /tmp/cc5AugyJ.o: In function `main':
    fig07_10.c:(.text+0x69): undefined reference to `convertToUpperCase'
    collect2: ld returned 1 exit status
    Code:
    #include <stdio.h>
    #include <ctype.h>
    
    void convertToUpperCase( char * );
    
    
    int main()
    {
    	char string[] = "characters and $32.98";
    
    	printf( "The string before conversion is: &#37;s", string );
    	convertToUpperCase( string );
    	printf( "\nThe string after conversion is: %s\n", string );
    	printf( "\nThe string after conversion is: %s\n",  string );
    
    	return 0;
    }
    
    
    
    void convertToUppercase( char *sPtr )
    {
    	while ( *sPtr != '\0' ) {
    		if ( islower( *sPtr ) )
    			*sPtr = toupper( *sPtr );
    
    		++sPtr;
    	}
    }

    I think gcc needs an extra argument but I don't understand why or what it is.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by yougene View Post

    Code:
    void convertToUpperCase( char * );
    void convertToUppercase( char *sPtr )
    Compare and contrast.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    Code:
    void convertToUpperCase( char * );
    ...should also be...
    Code:
    void convertToUpperCase(char* sPtr);
    Anything else is just bad practice. Do not leave out the parameter names in the prototypes.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

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