由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 问一个C++函数Parameter的问题
相关主题
谁来解释一下这个是compiler问题吗?A helloworld OpenMP question?
A aimple C++ questionreverse words, not the Microsoft one!!!
C 中的typedef 一问奇怪的问题:关于一个简单的malloc()小程序 (转载)
Use Visual .NET for C++ programming char ** pt1和 char * pt2[] 的区别在哪?
C++ online Test 又一题 (转载)What is wrong with the code?
这个C++程序为什么不能运行为什么foo1可以而foo2不行?
C++ 初级再初级问题菜鸟求教,一个c++的困惑
大侠们救命, C++ operator new 问题C的argc问题
相关话题的讨论汇总
话题: filename话题: char话题: int
进入Programming版参与讨论
1 (共1页)
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);
1 (共1页)
进入Programming版参与讨论
相关主题
C的argc问题C++ online Test 又一题 (转载)
const 指针类型转换这个C++程序为什么不能运行
问个fork cow的问题C++ 初级再初级问题
[转载] Re: [转载] 这样读多个文件对吗?大侠们救命, C++ operator new 问题
谁来解释一下这个是compiler问题吗?A helloworld OpenMP question?
A aimple C++ questionreverse words, not the Microsoft one!!!
C 中的typedef 一问奇怪的问题:关于一个简单的malloc()小程序 (转载)
Use Visual .NET for C++ programming char ** pt1和 char * pt2[] 的区别在哪?
相关话题的讨论汇总
话题: filename话题: char话题: int