这有效吗? [英] Does this works

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

问题描述

大家好,


我怀疑很久了。考虑一个结构

struct A {

int z;

}

struct n {

struct A * a;

int * y;

} * st;

这将有效

st -a -z = 10;

感谢adv

解决方案

raghu写道:


大家好,


我怀疑很久了。考虑一个结构

struct A {

int z;

}



缺少;


struct n {

struct A * a;

int * y;

} * st;

这将有效



尝试时发生了什么?


st -a -z = 10;



您认为st指向什么?在哪里初始化?


-

Ian Collins。


1月30日,10日:早上45点,Ian Collins< ian-n ... @ hotmail.comwrote:


raghu写道:


Hello Everyone,


我怀疑很长一段时间。考虑一个结构

struct A {

int z;

}



缺少;


struct n {

struct A * a;

int * y;

} * st;

这将有效



尝试时发生了什么?


st -a -z = 10;



您认为st指向什么?在哪里初始化?


-

Ian Collins。



oops抱歉结构A以''结尾; ''和本声明


st -a -z = 10;



在init函数中初始化,它填充了

结构的所有值。


raghu< ra ********* @ gmail.comwrote:


Hello Everyone,

我怀疑很长一段时间。考虑一个结构

struct A {

int z;

}



你忘记了;之后}


struct n {

struct A * a;

int * y;

} * st;


这将有效

st -a -z = 10;



是的,有两个条件:

- 你成功地为st />
分配内存 - 你成功地分配了内存对于st-> a

(如果您决定使用y,也适用于y)

-

Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org(希望现在还不算太晚)

(......它还能运作......)


Hello Everyone,

I have a doubt for a long time. consider a structure
struct A{
int z;
}
struct n{
struct A *a;
int *y;
}*st;
will this works
st -a -z = 10;
Thanks in adv

解决方案

raghu wrote:

Hello Everyone,

I have a doubt for a long time. consider a structure
struct A{
int z;
}

Missing ;

struct n{
struct A *a;
int *y;
}*st;
will this works

What happened when you tried it?

st -a -z = 10;

What do you think st points to? Where is it initialised?

--
Ian Collins.


On Jan 30, 10:45 am, Ian Collins <ian-n...@hotmail.comwrote:

raghu wrote:

Hello Everyone,

I have a doubt for a long time. consider a structure
struct A{
int z;
}


Missing ;

struct n{
struct A *a;
int *y;
}*st;
will this works


What happened when you tried it?

st -a -z = 10;


What do you think st points to? Where is it initialised?

--
Ian Collins.

oops sorry struct A ends with '' ; '' and this statement

st -a -z = 10;

initialized in init function which populates all the values of the
structure.


raghu <ra*********@gmail.comwrote:

Hello Everyone,

I have a doubt for a long time. consider a structure
struct A{
int z;
}

You forgot the ; after }

struct n{
struct A *a;
int *y;
}*st;

will this works
st -a -z = 10;

Yes, with two conditions:
- you succesfully allocate memory for st
- you succesfully allocate memory for st->a
(also for y if you decide to use y)
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it''s not too late)
(... and that it still works...)


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

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