要求提出意见:C的简要总结 [英] Comments requested: brief summary of C

查看:52
本文介绍了要求提出意见:C的简要总结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我正在撰写的一本书,我写了一篇简短的(7页)摘要

of C.这是一个经验丰富的程序员,他们做了
不知道C能够获得足够的信息来阅读和理解C程序。这并不意味着语言的100%完整

摘要,但那里的一切都应该是正确的。


如果有人有兴趣,请感受免费阅读并发送给我

评论。请注意,该材料受版权保护,此文件仅供审核,并且任何评论中包含的想法可以在书中全部或部分使用
,没有授予

提供评论的人的权利。但是我会通过

名称(如果需要)承认任何发送评论的人。


根据我的出版商的要求,信息是PDF格式,但是如果这个

对任何人都有问题,请给我发电子邮件,我可以发给你简单的

文字。


文件位于

http://www.proudlyserving .com / language / c.pdf


我已经为其他语言撰写了类似的摘要,并且已经或将会在适当的新闻组中发布



谢谢。


- Adam Barr
ad **** @ gte.net

解决方案

Adam Barr写道:

对于我正在撰写的一本书,我写了一篇简短的(7页)C总结。这是一个经验丰富的程序员,他们不知道C就能够获取足够的信息来阅读和理解C程序。它并不是100%完整的语言摘要,但其中的所有内容都应该是正确的。




不是。


-

Richard Heathfield: bi *** *@eton.powernet.co.uk

Usenet是一个奇怪的地方。 - Dennis M Ritchie,1999年7月29日。

C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

K& R答案,C书等:< a rel =nofollowhref =http://users.powernet.co.uk/etontarget =_ blank> http://users.powernet.co.uk/eton




" Adam Barr" <广告**** @ gte.net>在消息中写道

news:ce ************************** @ posting.google.c om ...

对于我正在撰写的一本书,我写了一篇简短的(7页)C总结。这是一个经验丰富的程序员,他们不知道C将能够获得足够的信息来阅读和理解C程序。它并不是100%完整的语言摘要,但其中的所有内容都应该是正确的。

如果有人有兴趣,请随时阅读并发送给我<评论。请注意,该材料受版权保护,本文档仅供审阅,任何评论中包含的想法可能会在本书中全部或部分使用,但不授予姓名(如果需要)承认任何发送评论的人。

根据我的出版商的要求,这些信息是PDF格式的,但如果这是
任何人的问题,给我发电子邮件,我可以用简单的文本发送给你。

文件是

http://www.proudlyserving.com/language/c.pdf


``C结尾的分号(;)。'''''


不,不是真的。按照这个定义,以下

有资格作为声明:


int foo;


声明是_not_ a声明。阅读c99的6.8。

``C将所有空白空间视为等效,因此换行符号

和缩进仅用于读取。''''


所以#define FOO 10

与#defineFOO10相同?

``没有大括号的单个语句也算作

代码块。''''

不,它算作单个语句。

``一个字符包含一个字节。单个字符被单引号包围,例如''a''和''x''。''''


我认为你应该还提到char是一个整数类型

,字符文字是int类型。否则

你的陈述可能会产生误导。

``字符串只是char类型的数组。按照惯例,

a字符串以0值终止,写为单个

字符''\0'''。''''


不够用。正如标准所说:

``字符串是一个连续的字符序列终止

由并包括第一个空字符。''''

``(你可以在第十个字节中添加一个不同的字符,

但它不会是一个正确终止的字符串

根据C约定)。 '''


如果没有

null字符,它就不会是一个字符串。

``char指针是通常分配给常量字符串,例如

city =" Boston";


它没有分配给``constant''''字符串(你应该把它称为字符串

literal)。它被分配了字符串文字衰减的地址。

``指针也被取消引用*,所以* city是城市指向的第一个字节

。事实上,指针和数组通常可以互换使用

,城市数组中的第一个字符可以是

引用为city [0]或* city。''' '


这可能会误导某人相信

指针和数组是相同的如果你没有

expound还有他们的差异。

``请注意,C不会检查指针的有效性,所以如果城市未初始化,* city

可能会导致崩溃,并且名称[ 20]

给出一个未定义的结果,如果名称按上面的方式分配,只需10个字符就可以获得

。''''


C?你的意思是C实现?

``允许指针算术并自动补偿指向的元素大小的
。''''

我会使用``object''''不是'`element''''

``更一般地说,array [n]相当于*(array + n)和在

事实被定义为这样。''''


不,不是。它相当于*((数组)+(n))

增加的parens很重要。如果您的方法实际上使用了
,则以下情况将会失败:


a [i,j];


这相当于*(a + i,j)


最终会取消引用j的价值

而不是*((a)+(i,j))

``typedef struct _record {

int element1; char element2;

struct _record * next;

} record,* record_ptr;''''


标准说以

下划线开头的标识符总是保留用作标识符

,文件范围。


``int array [ 20];

for(i = 0; i< 20; i ++)

{{code涉及array [i]; }''''

``i< sizeof array / sizeof array [0]''''

是更常见的约定


``注释用//表示'''''


只有在c99以下才是。

如果你的c89 / 90实现

_happens_来支持它们没关系。那当然,如果

可移植性是一个问题。

我已经为其他语言编写了类似的摘要,并且已经或将要在相应的新闻组中发布它们。

谢谢。

- Adam Barr
ad **** @ gte.net



2004年2月24日星期二07:38:50 +0000,Richard Heathfield写道:
< blockquote class =post_quotes> Adam Barr写道:

对于我正在撰写的一本书,我写了一篇简短的(7页)C总结。这是一个经验丰富的程序员谁不知道C将能够获得足够的信息来阅读和理解C程序。它并不意味着100%完整的语言摘要,但那里的一切都应该是正确的。
不是。




所以pdf是真的吗?我已经看到了其他语言组的相同帖子(明显取代了他们的语言

)所以我认为这是一种使用某个漏洞的某种

诈骗常见的浏览器或常见的pdf

阅读器。


对OP:如果你提供的文字很明确,你会得到更好的反馈

text或html,以便人们可以在他们回复时对文本进行剪切和粘贴。我找到了一个可以澄清的句子,但是当我无法轻易地切割并粘贴该句子时(似乎你的pdf有一些标志

不允许选择文本acroread)我没有努力通过所有这些来阅读



在pdf中,Adam Barr写道:一个int包含一个整数值,取决于平台,可以是2,4或8个字节。
是的,因为你使用了_can_这个词,但那些并不是唯一合法的

大小的int,读取你的句子后somone可能会想到。

值NULL分配给指针指示它们指向什么都没有。



更改是到可以你的判决可能导致某人相信

分配NULL是自动完成的,情况并非如此(尽管

编译器_could_选择初始化所有指针为零''不是

保证)


FWIW


-

NPV


大字打印,小字打印

Tom Waits - 向上走吧


For a book I am working on, I have written a brief (7 page) summary
of C. The intent of this is that an experienced programmer who did
not know C would be able to get enough information to read and
understand C programs. It is not meant to be a 100% complete
summary of the language, but everything in there should be correct.

If anyone is interested, please feel free to read it and send me
comments. Note that the material is copyrighted, this document is
provided for review only, and the ideas contained in any comments may
be used in the book, in whole or in part, with no rights granted to
the person who provided the comments. I will however acknowledge by
name (if desired) anyone who sends comments.

The information is in PDF form per my publisher''s request, but if this
is a problem for anyone, email me and I can send it to you in plain
text.

The file is at

http://www.proudlyserving.com/language/c.pdf

I have written similar summaries for other languages and have or will
post them in the appropriate newsgroups.

Thank you.

- Adam Barr
ad****@gte.net

解决方案

Adam Barr wrote:

For a book I am working on, I have written a brief (7 page) summary
of C. The intent of this is that an experienced programmer who did
not know C would be able to get enough information to read and
understand C programs. It is not meant to be a 100% complete
summary of the language, but everything in there should be correct.



It isn''t.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton



"Adam Barr" <ad****@gte.net> wrote in message
news:ce**************************@posting.google.c om...

For a book I am working on, I have written a brief (7 page) summary
of C. The intent of this is that an experienced programmer who did
not know C would be able to get enough information to read and
understand C programs. It is not meant to be a 100% complete
summary of the language, but everything in there should be correct.

If anyone is interested, please feel free to read it and send me
comments. Note that the material is copyrighted, this document is
provided for review only, and the ideas contained in any comments may
be used in the book, in whole or in part, with no rights granted to
the person who provided the comments. I will however acknowledge by
name (if desired) anyone who sends comments.

The information is in PDF form per my publisher''s request, but if this
is a problem for anyone, email me and I can send it to you in plain
text.

The file is at

http://www.proudlyserving.com/language/c.pdf

``Statements in C end with a semi-colon ( ; ).''''

No, not true. By that definition the following
qualifies as a statement:

int foo;

A declaration is _not_ a statement. Read 6.8 of c99.
``C treats all blanks space as equivalent, so line breaks
and indents are for readability only.''''

So #define FOO 10
is the same as #defineFOO10 ?
``A single statement without the braces also counts as a
block of code.''''

No, it counts as a single statement.
``A char holds a single byte. Single characters are
surrounded by single quotes, such as ''a'' and ''x'' .''''

I think you should also mention that char is an integer type
and the character literals are of type int. Otherwise
your statement can be misleading.
``Strings are simply arrays of type char. By convention,
a string is terminated with a 0 value, written as a single
character ''\0'' .''''

Not adequate enough. As the standard says:
``A string is a contiguous sequence of characters terminated
by and including the first null character.''''
``(you could put a different character in the tenth byte,
but it would then not be a properly-terminated string
according to C conventions).''''

It would not be a string whatsoever if there is no
null character.
``char pointers are often assigned to constant strings, for example
city = "Boston";

It is not assigned to ``constant'''' strings(you should call it a string
literal). It is assigned the address that the string literal decays to.
``Pointers are also dereferenced with * , so *city is the first byte
pointed to by city . In fact, pointers and arrays are often used
interchangeably, and the first char in the city array could be
referenced as city[0] or *city .''''

This might mistakingly lead someone to believe that
pointers and arrays are one in the same if you do not
expound further on their differences.
``Note that C does no checks for validity of pointers, so *city
will likely cause a crash if city is uninitialized, and name[20]
gives an undefined result if name is allocated as above with room
for only 10 chars .''''

C? You mean C implementations?
``Pointer arithmetic is allowed and automatically compensates
for the size of the element pointed to.''''

I would use ``object'''' not ``element''''
``More generally, array[n] is equivalent to *(array + n) and in
fact is defined as such.''''

No it isn''t. It is equivalent to *((array) + (n))
The added parens are important. If your method
was actually used then the following would
fail:

a[i, j];

Which would be equivalent to *(a + i, j)

Which would end up dereferencing the value of ``j''''
as opposed to *((a) + (i, j))
``typedef struct _record {
int element1; char element2;
struct _record * next;
} record, * record_ptr;''''

The standard says that identifiers that begin with an
underscore are always reserved for use as identifiers
with file scope.

``int array[20];
for (i = 0; i < 20; i++)
{ { code involving array[i]; } }''''
``i < sizeof array / sizeof array[0]''''
is the more common convention

``Comments are denoted by // ;''''

Only under c99 they are.
It doesn''t matter if your c89/90 implementation
_happens_ to support them. That is, of course, if
portability is a concern.
I have written similar summaries for other languages and have or will
post them in the appropriate newsgroups.

Thank you.

- Adam Barr
ad****@gte.net



On Tue, 24 Feb 2004 07:38:50 +0000, Richard Heathfield wrote:

Adam Barr wrote:

For a book I am working on, I have written a brief (7 page) summary
of C. The intent of this is that an experienced programmer who did
not know C would be able to get enough information to read and
understand C programs. It is not meant to be a 100% complete
summary of the language, but everything in there should be correct.
It isn''t.



So the pdf is real? I''ve seen the same post to other language groups (with
their language substituted obviously) so I assumed this was some kind of
scam using a vulnerability either in a common browser or a common pdf
reader.

To the OP: You will get better feedback if you provide the text as plain
text or html so that people could cut and paste the text when they
respond. I found one sentence that could be clarified, but when I couldn''t
cut and paste that sentence easily (seems your pdf has some flag that
disallows selecting text in acroread) I didn''t make the effort to read
through all of it.

In a pdf Adam Barr writes: An int holds an integer value, which can be 2, 4 or 8 bytes depending on
the platform. True because you used the word _can_ but those are not the only legal
sizes of int, wich somone might think after reading your sentence.
The value NULL is assigned to pointers to indicate that they point to
nothing.


Change that "is" to "can be". Your sentence could lead someone to believe
that assigning NULL is done automatically, which is not the case (though a
compiler _could_ choose to initialize all pointers to zero it''s not
guaranteed to)

FWIW

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up


这篇关于要求提出意见:C的简要总结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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