-
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: %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.
-
Quote:
Originally Posted by
yougene
Code:
void convertToUpperCase( char * );
void convertToUppercase( char *sPtr )
Compare and contrast.
-
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.