当前在线人数18406
首页 - 分类讨论区 - 电脑网络 - 葵花宝典版 - 同主题阅读文章

此篇文章共收到打赏
0

  • 10
  • 20
  • 50
  • 100
您目前伪币余额:0
未名交友
[更多]
[更多]
ask a simple question about int pointer.
[版面:葵花宝典][首篇作者:gmail] , 2007年11月28日23:02:02 ,1136次阅读,47次回复
来APP回复,赚取更多伪币 关注本站公众号:
[首页] [上页][下页][末页] [分页:1 2 3 ]
gmail
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 1 ]

发信人: gmail (gmail is good!), 信区: Programming
标  题: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Wed Nov 28 23:04:39 2007), 转信

I was asked such a question: how to determine the size of memory of the int
pointer pointed? for example

int GetTheSizeofMemory(int *buffer)

{

  int size;

   //enter your code here, to calculate the memory size of buffer point to.

  return size;

}

we can not use sizeof(buffer) to get the value, how should we do?

thanks.



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 71.76.]

 
Savant
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 2 ]

发信人: Savant (期待奇迹中), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Wed Nov 28 23:14:05 2007), 转信

find the diff b/w buffer + 1 and buffer

【 在 gmail (gmail is good!) 的大作中提到: 】
: I was asked such a question: how to determine the size of memory of the
int
: pointer pointed? for example
: int GetTheSizeofMemory(int *buffer)
: {
:   int size;
:    //enter your code here, to calculate the memory size of buffer point to.
:   return size;
: }
: we can not use sizeof(buffer) to get the value, how should we do?
: thanks.
: ...................


--

※ 修改:·Savant 于 Nov 28 23:14:23 修改本文·[FROM: 146.151.]
※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 146.151.]

 
gmail
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 3 ]

发信人: gmail (gmail is good!), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Wed Nov 28 23:15:09 2007), 转信


details,please?

what is b/w?



【 在 Savant (期待奇迹中) 的大作中提到: 】
: find the diff b/w buffer + 1 and buffer
: int



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 71.76.]

 
Savant
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 4 ]

发信人: Savant (期待奇迹中), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Wed Nov 28 23:24:32 2007), 转信

b/w = between :)

(char*)(buffer + 1) - (char*)(buffer)

【 在 gmail (gmail is good!) 的大作中提到: 】
: details,please?
: what is b/w?



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 146.151.]

 
gmail
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 5 ]

发信人: gmail (gmail is good!), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Wed Nov 28 23:34:13 2007), 转信



no, this will always return the sizeof(int *)


I mean if we have

int num[]={1,2,3,4,5,6,7,8,9,0};

int size=GetTheSizeofMemory(num);

how do you get the size as 10?


I was asked this question, I finally told him that I dont know how to do
this.




【 在 Savant (期待奇迹中) 的大作中提到: 】
: b/w = between :)
: (char*)(buffer + 1) - (char*)(buffer)



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 71.76.]

 
Savant
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 6 ]

发信人: Savant (期待奇迹中), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Wed Nov 28 23:36:10 2007), 转信

then good luck, he he

【 在 gmail (gmail is good!) 的大作中提到: 】
: no, this will always return the sizeof(int *)
: I mean if we have
: int num[]={1,2,3,4,5,6,7,8,9,0};
: int size=GetTheSizeofMemory(num);
: how do you get the size as 10?
: I was asked this question, I finally told him that I dont know how to do
: this.



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 146.151.]

 
gooddream
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 7 ]

发信人: gooddream (damn, damn, it is not right), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 00:55:24 2007)

size = sizeof num /sizeof *num;
--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 67.168.]

 
kfk
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 8 ]

发信人: kfk (狂风), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 09:36:30 2007), 转信

did you ever try it yourself?

【 在 gooddream (damn, damn, it is not right) 的大作中提到: 】
: size = sizeof num /sizeof *num;



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 128.194.]

 
cooling
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 9 ]

发信人: cooling (爽歪歪), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 10:34:11 2007), 转信

no way.
if they can do so, why do so many system calls need to pass buffer size as a
parameter?

【 在 gmail (gmail is good!) 的大作中提到: 】
: I was asked such a question: how to determine the size of memory of the
int
: pointer pointed? for example
: int GetTheSizeofMemory(int *buffer)
: {
:   int size;
:    //enter your code here, to calculate the memory size of buffer point to.
:   return size;
: }
: we can not use sizeof(buffer) to get the value, how should we do?
: thanks.
: ...................


--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 68.253.]

 
OverCloud
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 10 ]

发信人: OverCloud (天马行空), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 11:34:23 2007)

没有办法知道。

【 在 gmail (gmail is good!) 的大作中提到: 】
: I was asked such a question: how to determine the size of memory of the
int
: pointer pointed? for example
: int GetTheSizeofMemory(int *buffer)
: {
:   int size;
:    //enter your code here, to calculate the memory size of buffer point to.
:   return size;
: }
: we can not use sizeof(buffer) to get the value, how should we do?
: thanks.



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 63.117.]

 
joking
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 11 ]

发信人: joking (看一看), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 11:41:41 2007)

no way in C or C++, or there won't be buffer overflow problem.
--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 207.188.]

 
gmail
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 12 ]

发信人: gmail (gmail is good!), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 12:28:06 2007), 转信



the interviewer seemed unhappy for I told him I dont know the answer. Ju
st said,oh... That's OK, let's moving to another topic.

ai.............bad luck.


【 在 joking (看一看) 的大作中提到: 】
: no way in C or C++, or there won't be buffer overflow problem.



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 129.252.]

 
eta
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 13 ]

发信人: eta (矮塔), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 13:41:11 2007), 转信

did you get the job?

【 在 gmail (gmail is good!) 的大作中提到: 】
: the interviewer seemed unhappy for I told him I dont know the answer. Ju
: st said,oh... That's OK, let's moving to another topic.
: ai.............bad luck.



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 128.211.]

 
acectl
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 14 ]

发信人: acectl (磨), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 14:32:42 2007)

the answer is "No way". This is a trick question.
【 在 gmail (gmail is good!) 的大作中提到: 】
: the interviewer seemed unhappy for I told him I dont know the answer. Ju
: st said,oh... That's OK, let's moving to another topic.
: ai.............bad luck.



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 192.158.]

 
gmail
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 15 ]

发信人: gmail (gmail is good!), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 15:09:31 2007), 转信

how?

the interviewers was not statisfied with this question, and then only as
ked me another question then said bye to me.

the talk only lasted for 15 minutes.

May be I misunderstood his question, but he did read the code, let me wr
ite some code to return the value of the size.

I also told him that we can not use sizeof(buffer) to get the value, he
agreed, then I have no idea.


【 在 eta (矮塔) 的大作中提到: 】
: did you get the job?



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 129.252.]

 
kfk
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 16 ]

发信人: kfk (狂风), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 15:27:02 2007), 转信

either you misunderstood him, or he is stupid.

There's still very small chance he is a super NB person that solved
a big problem that has troubled a lot of NB persons for years.

【 在 gmail (gmail is good!) 的大作中提到: 】
: how?
: the interviewers was not statisfied with this question, and then only as
: ked me another question then said bye to me.
: the talk only lasted for 15 minutes.
: May be I misunderstood his question, but he did read the code, let me wr
: ite some code to return the value of the size.
: I also told him that we can not use sizeof(buffer) to get the value, he
: agreed, then I have no idea.



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 128.194.]

 
helpme
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 17 ]

发信人: helpme (范坚强), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 16:46:10 2007)

you should not just say "don't know",  you should have bullshitted whatever
you know...

【 在 gmail (gmail is good!) 的大作中提到: 】
: how?
: the interviewers was not statisfied with this question, and then only as
: ked me another question then said bye to me.
: the talk only lasted for 15 minutes.
: May be I misunderstood his question, but he did read the code, let me wr
: ite some code to return the value of the size.
: I also told him that we can not use sizeof(buffer) to get the value, he
: agreed, then I have no idea.



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 143.182.]

 
tdr
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 18 ]

发信人: tdr (没头脑), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 17:37:46 2007)

What kind of company asked you this question? What type of position?

【 在 gmail (gmail is good!) 的大作中提到: 】
: I was asked such a question: how to determine the size of memory of the
int
: pointer pointed? for example
: int GetTheSizeofMemory(int *buffer)
: {
:   int size;
:    //enter your code here, to calculate the memory size of buffer point to.
:   return size;
: }
: we can not use sizeof(buffer) to get the value, how should we do?
: thanks.



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 99.161.]

 
tdr
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 19 ]

发信人: tdr (没头脑), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 17:56:59 2007)

"I don't know" is a much better answer than "No way". It can be done.

【 在 helpme (范坚强) 的大作中提到: 】
: you should not just say "don't know",  you should have bullshitted
whatever
: you know...



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 207.47.]

 
thrust
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 20 ]

发信人: thrust (WoW 无限期冬眠中), 信区: Programming
标  题: Re: ask a simple question about int pointer.
发信站: BBS 未名空间站 (Thu Nov 29 17:58:15 2007)

how?
【 在 tdr (没头脑) 的大作中提到: 】
: "I don't know" is a much better answer than "No way". It can be done.
: whatever



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 65.219.]

[首页] [上页][下页][末页] [分页:1 2 3 ]
[快速返回] [ 进入葵花宝典讨论区] [返回顶部]
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996