b*********n 发帖数: 1258 | 1 想利用别人定义好的一个程序
int* LinearSuffixSort(char*& inputString, int& stringLength);
inputString is the pointer to the string to be sorted. stringLength is the l
ength of inputString.
===================
我的程序是这样的
#include "LinearSuffixSort.h"
using namespace std;
void main(int argc, char* argv[]){
char * fileName="abcdefg";
cout << LinearSuffixSort(fileName,7) << endl;
}
===================
Compile不通过
error C2665: 'LinearSuffixSort' : none of the 3 overloads can convert parame
ter 1 from type 'char *'
== |
k****f 发帖数: 3794 | 2 try this one
char filename[]="abcdefg";
l
【在 b*********n 的大作中提到】 : 想利用别人定义好的一个程序 : int* LinearSuffixSort(char*& inputString, int& stringLength); : inputString is the pointer to the string to be sorted. stringLength is the l : ength of inputString. : =================== : 我的程序是这样的 : #include "LinearSuffixSort.h" : using namespace std; : void main(int argc, char* argv[]){ : char * fileName="abcdefg";
|
b*********n 发帖数: 1258 | 3 我试了,同样的compilation error
真的很confusing
the
【在 k****f 的大作中提到】 : try this one : char filename[]="abcdefg"; : : l
|
P****i 发帖数: 12972 | 4 什么compiler?
你这么2句code,问题很多呀。
cout后面跟的是int指针;第二个参数你用的是const,也不对。
l
【在 b*********n 的大作中提到】 : 想利用别人定义好的一个程序 : int* LinearSuffixSort(char*& inputString, int& stringLength); : inputString is the pointer to the string to be sorted. stringLength is the l : ength of inputString. : =================== : 我的程序是这样的 : #include "LinearSuffixSort.h" : using namespace std; : void main(int argc, char* argv[]){ : char * fileName="abcdefg";
|
D*******a 发帖数: 3688 | 5 inputString是char *&,不是char *
l
【在 b*********n 的大作中提到】 : 想利用别人定义好的一个程序 : int* LinearSuffixSort(char*& inputString, int& stringLength); : inputString is the pointer to the string to be sorted. stringLength is the l : ength of inputString. : =================== : 我的程序是这样的 : #include "LinearSuffixSort.h" : using namespace std; : void main(int argc, char* argv[]){ : char * fileName="abcdefg";
|
k****f 发帖数: 3794 | 6 贴代码吧。
l
【在 b*********n 的大作中提到】 : 想利用别人定义好的一个程序 : int* LinearSuffixSort(char*& inputString, int& stringLength); : inputString is the pointer to the string to be sorted. stringLength is the l : ength of inputString. : =================== : 我的程序是这样的 : #include "LinearSuffixSort.h" : using namespace std; : void main(int argc, char* argv[]){ : char * fileName="abcdefg";
|
b*********n 发帖数: 1258 | 7 这几句是我刚才写的,修改了一下
char* fileName="abcdefg";
int len=strlen(fileName);
LinearSuffixSort(fileName,len);
还是不行,VC 6下,compile通过(no error),build的时候
=======================
error LNK2001: unresolved external symbol "int * __cdecl LinearSuffixSort(ch
ar * &,int &)" (?LinearSuffixSort@@YAPAHAAPADAAH@Z)
fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
=======================
谢谢
the
【在 P****i 的大作中提到】 : 什么compiler? : 你这么2句code,问题很多呀。 : cout后面跟的是int指针;第二个参数你用的是const,也不对。 : : l
|
k****f 发帖数: 3794 | 8 unresolved external symbol
那是你的lib没有设置上!!或者拼写错误。或者C程序被C++调用,忘记用extern "C"
总之,就是找不到那个函数
ch
【在 b*********n 的大作中提到】 : 这几句是我刚才写的,修改了一下 : char* fileName="abcdefg"; : int len=strlen(fileName); : LinearSuffixSort(fileName,len); : 还是不行,VC 6下,compile通过(no error),build的时候 : ======================= : error LNK2001: unresolved external symbol "int * __cdecl LinearSuffixSort(ch : ar * &,int &)" (?LinearSuffixSort@@YAPAHAAPADAAH@Z) : fatal error LNK1120: 1 unresolved externals : Error executing link.exe.
|
b*********n 发帖数: 1258 | 9 我觉得这个就是pass by reference
不知道我应该怎么pass char*& 才可以呀?
谢谢
the
【在 D*******a 的大作中提到】 : inputString是char *&,不是char * : : l
|
i*****s 发帖数: 5 | 10 char *& 只要传入char*就行了 ,参数变成了指针的引用,可以改变指针的地址。感觉
第一次是因为7不妥,7是常数,好像只能传给const int&。第二次的那个没有找到链接
,可能要extern 或者lib什么的 |
a****s 发帖数: 559 | 11 LinearSuffixSort(&fileName[0],len); |