Execute strlwr function times wrong. The source program such as the following:
#include <stdio.h> #include <string.h>void main () {char s[10]={"China"}; printf ("%s\n", STRLWR (s)); return 0 ;}
Error content such as the following:
eg6527a.c:in function ' main ':
Eg6527a.c:8:2:warning: ' Return ' with a value, in function returning void [enabled by default] return 0; ^in file included from Eg6527a.c:3:0:eg6527a.c:at top level:/usr/include/strlwr.h:1:14:warning: ' strlwr ' used but never defined [enabled by default] static char *strlwr (char *s); ^/tmp/cc6lxd8t.o:in function ' main ': eg6527a.c: (. text+0x79): Undefined reference to ' STRLWR ' Collect2:error:ld returned 1 exit status
Look for the reason, originally is the compatibility problem strlwr, STRUPR function is not the standard C function library, only can use in the VC,
These functions need to be customized under Linux gcc.
The detailed procedure is for example the following:
Write yourself a strlwr.h header file, such as the following:
Char *strlwr (char *s) {char *str; str = s; while (*str! = ') { if (*str >= ' A ' && *str <= ' Z ') { *s TR + = ' A '-' a '; } str++; } return s; }
Save it under the/usr/include folder
Then change the source file to:
#include <stdio.h> #include <string.h> #include <strlwr.h>void main () {char s[10]={"China"}; printf (" %s\n ", STRLWR (s)); return 0;}
Execute the program again at this time Gcc-o 6527a 6527a.c
To generate a running file 6527a
Execute the file./6527a
The result is: China
Convert the string "China" to: "China"
Error executing STRLWR function under Linux: LD returned 1 exit status