从C到Pascal的翻译 [英] Translating from C to Pascal

查看:75
本文介绍了从C到Pascal的翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我把以下几行翻译成pascal(delphi)吗?


让我解释一下我在找什么:


int i = 1; {在这一行中,一个整数变量被称为i。声明为
,并用1}初始化。

BYTE数据[2000] = {0}; {你的评论在这里......}

BITMAPINFOHEADER * bh =(BITMAPINFOHEADER *)数据; {你的评论在这里......}

RGBQUAD * pal =(RGBQUAD *)(data + sizeof(* bh)); {你的评论在这里......}

我对于在C / C ++中的含义非常困惑

我不明白为什么它在变量之前/在某些情况下键入和在

其他情况下它是后来的

我也不理解这种界限:


(BITMAPINFO) *)bh {a type cast?}

& specbuf {指针变量引用的数据?}

TIA。

Can anybody help me to translate the following lines to pascal(delphi)?

Let me explain what I''m looking for:

int i = 1; {In this line, an integer variable which is called "i" is
declared and it is initialised with 1}
BYTE data[2000]={0}; {your comments here...}
BITMAPINFOHEADER *bh=(BITMAPINFOHEADER*)data; {your comments here...}
RGBQUAD *pal=(RGBQUAD*)(data+sizeof(*bh)); {your comments here...}
I am very confused with the meaning that has the * in C/C++
I don''t understand why it precedes the variable/type in some cases and in
other cases it is later
Neither I understand this kind of lines:

(BITMAPINFO*)bh {a type cast?}
&specbuf {the data referenced by a Pointer variable?}
TIA.

推荐答案

Julian Maisano写道:
Julian Maisano wrote:
任何人都可以帮我翻译以下几行到pascal(delphi)吗?

让我解释一下我正在寻找:

int i = 1; {在这一行中,一个整数变量被称为i。
已声明并初始化为1}

BYTE数据[2000] = {0}; {你的评论在这里...}


在堆栈上创建一个包含2000个元素(BYTE类型)的数组。将

第一个元素设置为0.这可能不是作者的意思,但那可能是他所得到的


BITMAPINFOHEADER * bh =(BITMAPINFOHEADER *)数据; {你的评论在这里...}


指针是保存内存地址的变量。该行定义了一个

指针(称为bh)来保存名为

data的现有变量的地址。这是一种古老的,特别是无用的C ++风格。

RGBQUAD * pal =(RGBQUAD *)(data + sizeof(* bh)); {你的评论在这里...}


这似乎定义了另一个指针(pal)指向某些位于数据中间的b $ b中间 "作者可能一直试图访问聚合数据结构中的各个成员。这似乎不是很好。

好​​的代码。

我对C / C ++中*的含义非常困惑我不知道理解为什么它在某些情况下在变量/类型之前,在其他情况下它是后来


我很抱歉不得不告诉你这个,但是C ++语法很糟糕。其中大部分

都是从C语言继承而来的。语法通常被认为是C ++中一个很大的弱点。

我都不明白这种专栏:

(BITMAPINFO *)bh {a type cast?}


你懂了。那条线意味着让'假装bh是一个指针,持有

一些BITMAPINFO的地址,不管它是不是。

& specbuf {指针变量引用的数据?}


关闭。 &或地址。运算符,在内存中给出了一个

变量的位置。

TIA。
Can anybody help me to translate the following lines to pascal(delphi)?

Let me explain what I''m looking for:

int i = 1; {In this line, an integer variable which is called "i" is
declared and it is initialised with 1}
BYTE data[2000]={0}; {your comments here...}
Create an array of 2000 elements (of type BYTE) on the stack. Set the
first element to 0. That may not be what the author meant, but that''s
probably what he got.
BITMAPINFOHEADER *bh=(BITMAPINFOHEADER*)data; {your comments here...}
Pointers are variables that hold memory addresses. This line defines a
pointer (called "bh") to hold the address of an existing variable called
"data." This is an ancient, and particularly unhelpful, style of C++.
RGBQUAD *pal=(RGBQUAD*)(data+sizeof(*bh)); {your comments here...}
This seems to define another pointer ("pal") to point somewere in the
middle of "data." The author may have been trying to access individual
members of an aggregate data structure. This does not appear to be very
good code.
I am very confused with the meaning that has the * in C/C++
I don''t understand why it precedes the variable/type in some cases and in
other cases it is later
I''m sorry to have to tell you this, but C++ syntax blows. Most of it
was inherited from C. Syntax is generally considered the one big weak
spot of C++.
Neither I understand this kind of lines:

(BITMAPINFO*)bh {a type cast?}
You got it. That line means "let''s pretend that bh is a pointer holding
the address of some BITMAPINFO, whether it is not."
&specbuf {the data referenced by a Pointer variable?}
Close. The "&", or "address-of" operator, gives the location of a
variable in memory.
TIA.




希望这有帮助,

Jeff



Hope this helps,
Jeff


首先

谢谢。你给了我很多帮助


我有另外一个问题:


这些行是否与C ++相同?


whatevertype * name


* whatevertype name


whatevertype * name


whatevertype name *

First of all
Thanks. You helped me a lot

I have another question:

Are these lines equivalent in C++?

whatevertype* name

*whatevertype name

whatevertype *name

whatevertype name*

我很遗憾不得不告诉你这个,但是C ++的语法很糟糕。其中大部分都是继承自C语法。语法通常被认为是C ++的一大弱点。
I''m sorry to have to tell you this, but C++ syntax blows. Most of it
was inherited from C. Syntax is generally considered the one big weak
spot of C++.




mmmm ,,,,

你说的有很多相关性,因为根据我的看法

在另一篇文章中,可以看出你是一位伟大的专家。


Julian Maisano,La Plata,Arg



mmmm,,,,
What you say has a lot of relevance, because according to what I was looking
in another posts, it is seen that you are a great expert.

Julian Maisano, La Plata, Arg


2003年12月30日星期二23:50:52 -0500,Jeff Schwab< je ** ****@comcast.net>

在comp.lang.c ++中写道:
On Tue, 30 Dec 2003 23:50:52 -0500, Jeff Schwab <je******@comcast.net>
wrote in comp.lang.c++:
Julian Maisano写道:
Julian Maisano wrote:
可以有人帮我把以下几行翻译成pascal(delphi)吗?

让我解释一下我在找什么:

int i = 1; {在这一行中,一个整数变量被称为i。
已声明并初始化为1}

BYTE数据[2000] = {0}; {您的评论在这里......}
Can anybody help me to translate the following lines to pascal(delphi)?

Let me explain what I''m looking for:

int i = 1; {In this line, an integer variable which is called "i" is
declared and it is initialised with 1}
BYTE data[2000]={0}; {your comments here...}



在堆栈上创建一个包含2000个元素(BYTE类型)的数组。将
第一个元素设置为0.这可能不是作者的意思,但那可能是他得到的。



Create an array of 2000 elements (of type BYTE) on the stack. Set the
first element to 0. That may not be what the author meant, but that''s
probably what he got.




设置所有2000BYTE。元素为0.


-

杰克克莱恩

主页: http://JK-Technology.Com



comp.lang.c的常见问题解答 http://www.eskimo.com/~scs/ C-faq / top.html

comp.lang.c ++ http://www.parashift.com/c++-faq-lite/

alt.comp.lang.learn.c-c ++ ftp://snurse-l.org/pub/acllc-c++/faq



Sets all 2000 "BYTE" elements to 0.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq


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

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