这个作业好吗? [英] Is this assignment ok?

查看:80
本文介绍了这个作业好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

char * pA [5];

char * pB [5];


pA = pB;


这不编译。


第二个想法,是吗?
(x)char * pA [5]意思是

(a)指向5个字符的指针或者

(b)指向一个角色的5个指针 ?


如果(x)==(b)那么(a)如何宣布?


任何帮助都将受到赞赏。< br>

解决方案

Colin JN Breame写道:

char * pA [5];
char * pB [5];

pA = pB;

这不会编译。


不足为奇。


pA是一个数组的名称(一个5个指向char的数组)

pB是数组的名称(指向char的5个指针的数组)


pA和pB都不可更改,尽管它们的/ contents /是。

再想一想,
(x)char * pA [5]是什么意思
(a)指向5个字符的指针或者
(b)指向一个角色的5个指针 ?


(b)

如果(x)==(b)那么(a)如何宣布?


char(* pA)[5];

任何帮助都将不胜感激。



-


Lew Pitcher,IT顾问,应用程序架构

企业技术解决方案,道明银行金融集团


(意见表达这是我自己的,而不是我的雇主的)


在文章< bh ********** @ oravannahka.helsinki .fi>,

Joona I Palaste< pa ***** @ cc.helsinki.fi>写道:

Colin JN Breame< c。********** @ durham.ac.uk>潦草地写下:

(a)指向5个字符的指针或


如果(x)==(b)那么(a)如何宣布?



char(* pB)[5];




这是指向(和数组)五个字符指针的指针。


指向(数组)5个字符的指针将是:

char * p [5];


- Brett


>>第二个想法,

(x)char * pA [5]意味着


等于

* pa0 * pa1 * pa2 * pa3 * pa4

(参见argv提示提示!)

(a)指向5个字符的指针或者
(b)指向一个角色的5个指针 ?



这意味着指向一个角色的5个指针。




对我来说,这是一个指向字符串的5个指针('aka' ;字符数组")

if(x)==(b)那么(a)如何声明?


char(* pB)[5];




因为IMO *在[]之前占优势(是吗?如果我不正确,请帮助)

我说它是'char *'的5 ptrs因此(* pb)[5]相当于* pb [5]


-

- Jan Engelhardt


char *pA[5];
char *pB[5];

pA = pB;

This doesnt compile.

On second thoughts, does
(x) char *pA[5] mean
(a) "A pointer to 5 characters" or
(b) "5 pointers to a character" ?

If (x) == (b) then how would (a) be declared?

Any help would be appreciated.

解决方案

Colin JN Breame wrote:

char *pA[5];
char *pB[5];

pA = pB;

This doesnt compile.
Not surprisingly.

pA is the name of an array (an array of 5 pointers to char)
pB is the name of an array (an array of 5 pointers to char)

Neither pA nor pB is alterable, although their /contents/ are.
On second thoughts, does
(x) char *pA[5] mean
(a) "A pointer to 5 characters" or
(b) "5 pointers to a character" ?
(b)
If (x) == (b) then how would (a) be declared?
char (*pA)[5];
Any help would be appreciated.


--

Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer''s)


In article <bh**********@oravannahka.helsinki.fi>,
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:

Colin JN Breame <c.**********@durham.ac.uk> scribbled the following:

(a) "A pointer to 5 characters" or


If (x) == (b) then how would (a) be declared?



char (*pB)[5];



That''s a pointer to (and array of) five pointers to characters.

A pointer to (an array of) 5 characters would be:
char *p[5];

-- Brett


>> On second thoughts, does

(x) char *pA[5] mean
is _roughly_ equivalent to
*pa0 *pa1 *pa2 *pa3 *pa4
(see argv hint hint!)
(a) "A pointer to 5 characters" or
(b) "5 pointers to a character" ?



It means 5 pointers to a character.



For me this is 5 pointers to a string (′aka "character array")

If (x) == (b) then how would (a) be declared?



char (*pB)[5];



Because IMO * takes precende before [] (does it? please help if I am incorrect)
I say it''s 5 ptrs to "char*" and thus (*pb)[5] is equivalent to *pb[5]

--
- Jan Engelhardt


这篇关于这个作业好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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