作者zptdaniel ()
看板C_and_CPP
标题[问题] 如何回传字串指标中的某个记忆体位址?
时间Mon Mar 23 00:20:52 2009
http://rafb.net/p/FXzfKy46.html
这是C++ primer plus 第八章的练习题第六题
题目的一部分是要求要传入一个char指标阵列给函式,
然後要回传其中最长字串的记忆体位址。
我卡在回传记忆体位址的地方,不知道该怎麽修改才对。
请板友们帮我看看,谢谢!
--------------------------------------
我把部分的题目贴上来好了
The program also should include a specialization
that takes an array of pointers-to-char as an
argument and the number of pointers as a second
argument and which returns the address of the
longest string. If there are more than one string
having the longest length, the function returns the
address of the first one tied for longest.
Test the specialization with an array of 5 string
pointers.
我想问的就是上面这件事情..
P.S. C++真不好学啊...虽然学过C..
--
我以为远方 会有新的风景
却在每一个异地 流浪回望着记忆
"For the way I live" by Tizzy Bac
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.194.100.216
1F:推 Ebergies:其实我想说的是回传记忆体位址似乎不是 C++ 才有的东西.. 03/23 00:25
2F:→ Ebergies:不过理论上你应该要用 template 写才对吧? 03/23 00:27
3F:→ zptdaniel:15我知道不是C++才有的东西..不过我真的不会T_T 03/23 00:28
4F:→ zptdaniel:我是不会取那个记忆体位址啦.. 03/23 00:28
5F:→ zptdaniel:不知道该怎麽做Q_Q 03/23 00:28
6F:推 Ebergies:你的程式想做什麽我看不太懂, 问题是出在跑不完吗 03/23 00:33
7F:推 POSIX:建议你讲解一下 你各个functyion 在做什麽 一头雾水 03/23 00:35
※ 编辑: zptdaniel 来自: 123.194.100.216 (03/23 00:37)
8F:→ zptdaniel:主要想问int* maxn(char *,int n=5) 这个函式 03/23 00:38
9F:→ zptdaniel:这个函式要做的事情就是上面那段英文题目 03/23 00:38
10F:推 Ebergies:为啥要用 int* 呢? 而且思考一下 array of pointers-to-c 03/23 00:45
11F:→ Ebergies:har 的意义是什麽 03/23 00:50
12F:→ zptdaniel:谢谢!我写出来了^^ 03/23 11:00