请问链接错误unresolved external symbol问题
程序代码:
# include <stdio.h> # define N 5 # define n 255 void str_sort(int, char **); int str_cmp(char, char); void Swap(char **, char **); int main(void) { char str[N][n]; char *pstr[N]; int i = 0; for (i = 0; i < 5; i++) { scanf("%s", str[i]); pstr[i] = str[i]; } str_sort(N, pstr); for (i = 0; i < 5; i++) printf("%s\n", *pstr[i]); return 0; } void str_sort(int L, char ** pstr) { int i; bool IsSwap; IsSwap = true; while (IsSwap) { IsSwap = false; for (i = 0; i < L-1; i++) if (str_cmp(*(pstr[i+1]), *pstr[i]) < 0) { Swap(pstr+i+1, pstr+i); IsSwap = true; } } } int str_cmp(char * str1, char *str2) { while((*str1 != '\0') || (*str2 != '\0')) if (*str1 > *str2) return 1; else if (*str1 < *str2) return -1; else { str1++; str2++; } return 0; } void Swap(char ** a, char ** b) { char * t; t = *a; *a = *b; *b = t; }
想实现按字典顺序排序字符串
编译没有问题,链接时显示
error LNK2001: unresolved external symbol "int __cdecl str_cmp(char,char)" (?str_cmp@@YAHDD@Z)
请问是怎么回事啊?
(还没有检查程序正确性,链接没通过。。。)
(字符串函数是要求自己写的)
万分感谢!!
[此贴子已经被作者于2017-11-26 11:35编辑过]