Error executing STRLWR function under Linux: LD returned 1 exit status

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.