本文介绍了未定义的引用`strlwr“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是如文本COM pressor,读普通文本和变成数字,每一个字都有一个编号。它编译于DEVC ++,但并没有结束,但是,它并没有在Ubuntu 13.10编译。我发现了一个错误,如在标题在Ubuntu未定义参考`strlwr',我的code是有点长,所以我无法张贴在这里,但错误之一就是从这里开始:

  // operatinal这里funcitons
诠释的main()
{    INT I = 0,请选择;    字符文件名[50],textword [40],找到[20],插入[20]中,删除[20];    FILE * FP,* FP2,FP3 *;    的printf(请输入文件名:);    fflush(标准输出);    scanf函数(%S,文件名);    FP = FOPEN(文件名,R);    FP2 = FOPEN(yazi.txt,W +);    而(FP == NULL)
    {        的printf(错误的文件名,请重新输入文件名:);        fflush(标准输出);        scanf函数(%S,文件名);        FP = FOPEN(文件名,R);    }    而(!的feof(FP))    {         而(的fscanf(FP,%S,textword)== 1)        {            strlwr(textword);            而(!ispunct(textword [I]))
            我++;            如果(ispunct(textword [I]))            {                I = 0;                而(textword [I]!='\\ 0')
                我++;                一世 - ;                而(ispunct(textword [I]))
                一世 - ;                我++;                I = 0;                而(因而isalpha(textword [I]))
                我++;                textword [I] ='\\ 0';            }            ADDNODE(textword);        }    }.... //主继续


解决方案

strlwr()不是标准的C函数。也许它是由一个实现在您使用其它编译器不提供。

您可以自己轻松地实现它:

 的#include<&string.h中GT;
#包括LT&;&文件ctype.h GT;字符* strlwr(字符*海峡)
{
  无符号的char * p =(无符号字符*)海峡;  而(* P){
     * p值= tolower的(* P);
      p ++;
  }  返回海峡;
}

My code is like a text compressor, reading normal text and turns into numbers, every word has a number. It compiles in DevC++ but does not end, however, it does not compile in Ubuntu 13.10. I'm getting an error like in the title in Ubuntu "undefined reference to `strlwr'", my code is a little long so I am not able to post it here, but one of the error is from here:

//operatinal funcitons here


int main()
{

    int i = 0, select;

    char filename[50], textword[40], find[20], insert[20], delete[20];

    FILE *fp, *fp2, *fp3;

    printf("Enter the file name: ");

    fflush(stdout);

    scanf("%s", filename);

    fp = fopen(filename, "r");

    fp2 = fopen("yazi.txt", "w+");

    while (fp == NULL)
    {

        printf("Wrong file name, please enter file name again: ");

        fflush(stdout);

        scanf("%s", filename);

        fp = fopen(filename, "r");

    }

    while (!feof(fp))

    {

         while(fscanf(fp, "%s", textword) == 1)

        {

            strlwr(textword);

            while (!ispunct(textword[i]))
            i++;

            if (ispunct(textword[i]))

            {

                i = 0;

                while (textword[i] != '\0')
                i++;

                i--;

                while (ispunct(textword[i]))
                i--;

                i++;

                i=0;

                while (isalpha(textword[i]))
                i++;

                textword[i] = '\0';

            }

            addNode(textword);

        }

    }

.... //main continues
解决方案

strlwr() is not standard C function. Probably it's provided by one implementation while the other compiler you use don't.

You can easily implement it yourself:

#include <string.h>
#include<ctype.h>

char *strlwr(char *str)
{
  unsigned char *p = (unsigned char *)str;

  while (*p) {
     *p = tolower(*p);
      p++;
  }

  return str;
}

这篇关于未定义的引用`strlwr“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-16 21:15