本文介绍了声明一个返回指向1-d数组的指针的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何声明一个向一维数组返回指针

的函数?

How can I declare a function that returns a pointer
to one dimensional array ?

推荐答案




Do你最好的努力和发布它。这是基本的。


(提示:malloc())


-

Emmanuel

C-FAQ:

C库:



Do your best effort nd post it. It''s basic.

(hint : malloc())

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

..sig under repair





尽你所能并发布它。这是基本的。


(提示:malloc())

-

Emmanuel

C-FAQ:

C库:


" Mal nommer les choses c''est ajouter du malheur au

monde。 - Albert Camus。



Do your best effort and post it. It''s basic.

(hint : malloc())
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Mal nommer les choses c''est ajouter du malheur au
monde." -- Albert Camus.




就像你声明任何其他功能一样,只需记住

局部变量的范围仅限于函数内。所以你必须

返回一个指向动态分配内存的指针,或者返回一个静态变量。


欢呼,

forayer


-

如果你真的是一个真正的追求者,那么你生命中至少需要

尽可能地怀疑所有事情。

- Rene Descartes


Like you declare any other funtion, just remember that the scope of
local variables are restricted to within the function. So you have to
return a pointer to dynamically allocated memory, or to a static variable.

cheers,
forayer

--
If you would be a real seeker after truth, it is necessary that at least
once in your life you doubt, as far as possible, all things."
-- Rene Descartes


这篇关于声明一个返回指向1-d数组的指针的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 01:42
查看更多