什么是指针点 [英] What is the Point of Pointer's

查看:102
本文介绍了什么是指针点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C的学习程序员,我想知道为什么有人会使用

指针而不是直接指向!

I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!

推荐答案

在文章< yv ******************** @ comcast.com>,

Bill Potter< lo * *******@comcast.net>写道:
In article <yv********************@comcast.com>,
Bill Potter <lo********@comcast.net> wrote:
我是C语言的学习程序员,我想知道为什么有些人会使用
指针而不是直接指向!
I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!




我们在人类语言中使用指针的原因相同,例如

" home"而不是17859 Main Street

我们身后的汽车而不是注册没有KN5567YZ的汽车

你而不是Bill Potter


-

G?ran Larsson http://www.mitt-eget.com/


Bill Potter写道:
Bill Potter wrote:
我是C的学习程序员,我想知道为什么有人会使用
指针而不是直接指向!
I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!




假设您在汽车经销商和经销商处购买汽车

询问您喜欢哪辆车,您做什么?


1.在几辆车上__Point__ ...





2.去每辆车,然后移动他们每个人都直接在经销商处?
经销商?

如果您对效率感到担忧,可能会排在第一位。您可以通过指向它们来更快地将

推荐给更多的汽车,而不是直接将它们移动到您面前。

一个接一个。


这有帮助吗?

Mark F. Haigh
mf ***** @ sbcglobal .net




" Bill Potter" <螺******** @ comcast.net>在留言中写道

新闻:yv ******************** @ comcast.com ...

"Bill Potter" <lo********@comcast.net> wrote in message
news:yv********************@comcast.com...
我我是C的学习程序员,我想知道为什么有些人会使用
指针而不是直接指向!
I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!




有很多原因! 2个简单的:


1)当将一个大型结构传递给一个函数时,我们不想复制每个

元素并将速度减慢到一个蜗牛 - 步伐。所以传递一个指针,

非常快。


2)如果你想将一些信息传递给一个函数并且

函数修改一些数据。例如排序功能。我们将一个指向数组的

指针传递给函数,并让它完成所有工作。


基本上,指针可以加快速度。它们还允许使用malloc()或等效的动态内存分配
。事情开始变得更高级

当你指点指针时;-)

Allan



for many reasons! 2 simple ones:

1) when passing a large structure to a function, we dont want to copy every
element and slow things down to a snail-pace. So pass a pointer instead,
which is very quick.

2) what if you want some information to be passed to a function and that
function modifies some data. For example a sort function. We pass a
pointer to an array to the function and let it do all the work.

Basically, pointers speed things up. They also allow dynamic memory
allocation using malloc() or equivalent. Things start to get more advanced
when you have pointers to pointers ;-)
Allan


这篇关于什么是指针点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆