0

我收到以下 C 程序的错误消息,该程序假设将字符串中的一个单词更改为大写字母。

1>verkefni06.obj : error LNK2019: unresolved external symbol _strhlt referenced in function _main
1>c:\kit\skilaverk06\Debug\skilaverk06.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这是我到目前为止得到的代码,非常感谢任何导致代码工作的帮助。

#include <stdio.h>
#include <string.h>
#include <ctype.h>
pragma warning(disable : 4996)
pragma warning(disable : 4550)
/* strindex:  return index of t in s, -1 if none */



/* getline: get line into s, return length */

int getline (char s[], int lim)
{
   int c, i;

   i = 0;
    while (--lim > 0 && (c=getchar()) != EOF && c != '\n')
      s[i++] = c;
   s[i] = '\0';
   return i;
}

 /* strindex: return index of t in s , -1 if none */
int strindex (char s[], char t[])
{
   int i, j, k;

   for (i=0; s[i] != '\0'; i++){
      for (j=i, k=0; t[k] != '\0' && s [j]==t[k]; j++, k++)
         ;
      if (k > 0 && t[k] == '\0')
         return i;
    }
   return -1;
}


 int strhlt(char sz[], char szHigh[]); 

main()
{ 

   char sz [60];

   strcpy;

   getline (sz,60);
   getline (sz, 60);

   strhlt (sz,"write" ); 
   getline ("%s",60);


   printf("skrifadu stutta setningu (mest 60 stafabil): ");
   printf("\n\nRitadu ordid sem breytist i hastafi (mest 10 stafi): %s", sz);

   getchar();
   return 0;
}
4

2 回答 2

1

There is no definition for strhlt() in your code and it is not a library function too.

only declaration is available.

int strhlt(char sz[], char szHigh[]);

so during linker time, you are getting this error.

于 2013-10-16T10:12:18.597 回答
1
int strhlt(char sz[], char szHigh[]); 

链接编辑器正在寻找该函数的定义。它不在这个文件中。您是从其他地方链接它吗?

如果是这种情况,您需要一个extern

extern int strhlt(char sz[], char szHigh[]); 
于 2013-10-16T09:51:50.740 回答