请帮助我与指针-我很迷失 [英] Please help me with Pointers - I'm so lost

查看:61
本文介绍了请帮助我与指针-我很迷失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello World,

我想知道是否有人可以逐步解释指针的工作方式.我知道它们是什么,但是我在概念化不同情况时遇到了麻烦.例如,这些功能分别做什么?

1.指针1 =指针2-> next;

2.指针4 =指针1;

3.指针4->数据=指针1->数据;

4.指针4->下一个->数据=指针1->数据;


我不太明白->"是什么或它的意思.我也不太了解下一个"的概念.如果有人可以将其分解为我的基本知识,我将非常感激,因为我拼命试图在我的数据结构课程中取得进步,但实际上并不能解决这个问题.


预先感谢,
Jennifer

Hello World,

I was wondering if someone could explain STEP BY STEP how pointers work. I know what they are but I''m having trouble conceptualizing different situations. For example, What does each of these do?

1. pointer1 = pointer2->next;

2. pointer4 = pointer1;

3. pointer4->data = pointer1->data;

4. pointer4->next->data = pointer1->data;


I dont really understand what "->" does or what it means. I also don''t quite understand the concept of "next". I would be so grateful if someone could break it down to the basics for me because I''m desperately trying to move ahead in my data structures class but really can''t wrap my brain around this.


Thanks in advance,
Jennifer

推荐答案

这在我上学时对我有帮助
http://www.youtube.com/watch?v=i49_SNt4yfk [
This helped me when I was in school
http://www.youtube.com/watch?v=i49_SNt4yfk[^]


也请在此处查看.简单整洁

http://cslibrary.stanford.edu/106/ [
Also check out here. Simple and neat

http://cslibrary.stanford.edu/106/[^]


使用->"时,表示您要获取内存中的数据按
旁边的成员名称 ->"根据上面的用法,数据结构可能定义为
when you are using "->",it means you want to get the data in memory by the member name next to
"->" .And according to what you used above,the data structure might be defined like
struct tagList
{
    int data;
    struct tagList *next;
};



并且指针应该是



and the pointers should be

struct tagList *pointer1,*pointer2,*pointer3,*pointer4;



如果pointer2 =& tmpList1;
然后
指针1 =指针2->下一个;
这意味着指标2 = tmp1.next;

如果指针4 =& tmpList2;
然后
指针4->数据=指针2->数据;
这意味着tmpList2.data = tmpList1.data;
因为指针2->数据是*(pointer2).data,而*(pointer2)是tmpList1;
希望对您有所帮助.



if pointer2 = &tmpList1;
then
pointer1 = pointer2->next;
it means pointer2 = tmp1.next;

if pointer4 = &tmpList2;
then
pointer4->data = pointer2->data;
it means tmpList2.data = tmpList1.data;
because pointer2->data is *(pointer2).data,and *(pointer2) is tmpList1;
hope it will helpful.


这篇关于请帮助我与指针-我很迷失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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