搜档网
当前位置:搜档网 › used to与be used to用法辨析

used to与be used to用法辨析

used to与be used to用法辨析
used to与be used to用法辨析

used to表示过去的习惯性动作,过去如此,现在不再这样了。常译作“过去常常”。如:He used toplay basketball when he was young. 他年轻的时候常常打篮球。There used to be an apple tree here. 过去这儿曾经有棵苹果树。

be used to do表示“被用来做某事”。如:Wood is often used to make desks and chairs. 木头常常被用来制作桌椅。

be used to doing /n. 表示“习惯于”某一客观事实或状态,不强调动作,to是介词,后面接名词或动名词。如:He is used to hard work. 他习惯于艰苦的工作。She is not used to eating Chinese food. 她不习惯吃中餐。

在日常学习中,以下四组短语是很容易混淆的,同学们在使用时要弄清它们的异同点,下面将它们的具体用法进行详细介绍:★arrive in,arrive at,get to和reach的区别

1.He arrived ______ Shanghai yesterday.

A.at

B.in

C.of

D./

2.My friend was reading when I _____ the reading room.

A.got

B.arrived

C.arrived at

D.reached to

3.When I _____ school, the class had begun.

A.arrive

B.got to

C.got at

D.reach in

【解析】arrive,get和reach都表到达。arrive是不及物动词,后面要接介词in或at再加宾语,arrive in表到达大地点,arrive at表到达小地点。get后需加to再加宾语。reach是及物动词,后面可直接接宾语。arrive in Tianjin=get to Tianjin=reach Tianjin,故这三道题选B、C、B。

★be made of,be made from,be made in,be made by 和be made up的区别

4.The desk is made_____ wood.

A.in

B.from

C.of

D.by

5.Beer is made _____ wheat and something else.

A.in

B.of

C.by

D.from

6.This kind of watch is made _____ China.

A.of

B.in

C.by

D.from

7.The web is made ______ millions of documents called web pages.

A.of

B.from

C.in

D.up of

【解析】be made of表示仍可以看得出原材料的样子;而be made from表示原材料已经过变化,看不出原材料的样子了。be made in 后接地点表示产于某地,be made by表示由谁制作,be made up of 表示由什么组成。故这4道题依次选C、D、B、D。

★used to do/be,be used to do sth.,be used for doing sth.和be/get used to doing sth.的区别

8.My sister used _____ a teacher.

A.to be

B.to do

C.doing

D.do

9.These books ______ improve students hearing.

https://www.sodocs.net/doc/758701445.html,ed to

B.are used to

C.are used for

https://www.sodocs.net/doc/758701445.html,ed for

10.Tom _______ in bed.

https://www.sodocs.net/doc/758701445.html,ed to read

B.is used to read

C.is used for reading

D.is used to reading

【解析】used to do/be表示过去常常做某事,be used to do sth.和be used for doing都表示被用来做某事,be/get used to doing sth.表示习惯于做某事。第8题意思是我姐姐以前是老师,故选A。第9题意思是这些书被用来提高学生的听力,故选B。第10题意思是Tom习惯了在床上看书,故选D。

★prefer to do…rather than do…,prefer sth./doing sth. to sth./doing sth.和rather than的区别

11.I prefer_____ there by train rather than _____there by plane.

A.to go,go

B.going,going

C.go,go

D.go,to go

12.I prefer______ to _______ TV.

A.reading,watch

B.read watch

C.reading,watching

D.read,watching

13.He is a musician ______ a teacher.

A.rather

B.than

C.rather than

D.would rather

【解析】prefer to do…rather than do…——宁愿……也不……;prefer sth./doing sth. to sth./doing sth.——与……相比,更喜欢……,但前后形式要一致。rather than——与其、不愿。第11题意思是我宁愿坐火车去也不愿意坐飞机去,故选A。第12题意思是比起看电视,我更喜欢读书,故选C。第13题意思是与其说他是教师不如说他是音乐家,故选C。

used to的用法

used to的用法 used to是一个固定结构,它的意思是“过去经常、以前常常”,它的后面用动词原形,它表示过去存在某种状态或者过去的某种经常性、习惯性的行为或者动作,并意味着这种动作目前已经不存在,所以它只能用一般过去时,不能用现在时态。 1. 它的陈述句的肯定形式:主语+used to+动词原形。 例如:I used to play with my friends after school. 过去放学后我常常和朋友们一起玩。 2. 它的否定形式:主语+didn’t+use to+动词原形。 例如:You didn’t use to like pop songs. 你过去常常不喜欢流行歌曲。 3. 它的一般疑问句形式:Did+主语+use to+动词原形+其他? 例如:Did your sister use to be quiet? 你的妹妹过去常常是很安静吗? 4. used to的状语可以用副词always,often,sometimes等,但是仍然是过去的习惯,不是指现在的 习惯,所以不能用一般现在时。 例如:He always used to be late for class. 他过去常常上课迟到。 5. used to可以用在there be结构中表示“过去经常有”的意思。 例如:There used to be a lot of fishes in this river. 过去这条小河常常有许多鱼。 6. be used to do something的意思是“被用来做某事”,是动词短语use ...to do的被动语态结构, used是动词的过去分词。它可以用各种时态。 例如:Knives are used to cut things.小刀是用来切东西的。 7. be used to doing something的意思是“习惯于做某事”,to的后面用动名词,它可以用现在、 过去和将来等时态,be可以用get,become连系动词代替。 例如:My father is used to living in the village. 我爸爸习惯于住在小山村。 语法专练 1.Mary, you _____ be short, but now you are tall. A. were B. are C. use to D. used to 【答案与解析】答案是D。本句子是考查动词短语used to的用法。从本句子的意思理解是用used to表示“过去常常很矮”的意思。 2 My mother _____ us stories when we were children. A. was used to tell B. is used to telling C. used to tell D. used to telling 【答案与解析】答案是C。从本句子的意思“我妈妈过去常常给我们讲故事”可以理解是用used to+动词原形表示过去常常。 3 _______ used to______ an old bookshelf in my room. A. There; be B. There; have C. It; be D. There; having 【答案与解析】答案是A。本句子是考查there be和used to连用的用法,表示“过去常常有”的意思。 4 There used to be a river here,______? A. used there B. didn’t there C. wasn’t it D. did it 【答案与解析】答案是B。本句子是考查反意疑问句的用法,前面是肯定形式,后面用

used to的用法练习

used to 练习 一.选择填空 1. There ________ a lot of red-crowned cranes in this area. A.was used to B.was used to be https://www.sodocs.net/doc/758701445.html,ed to https://www.sodocs.net/doc/758701445.html,ed to be 2. She used to ______ with her parents, but now she is used to ______ with her classmates at school. (泰州) A. live; living B.live; live C.living; living D.living; live 3. He used to ____ in a small village, but now he has been used to ___ in the big city. (镇江) A. live; living B.live; live C.living;living D.living; live 4. Mrs Green _______ go to hospital, but now she is in good health. A. has to B.need to https://www.sodocs.net/doc/758701445.html,ed to D.ought to 5. My grandfather _______a policeman when he was young. A. use to be B. used to is C. used to are D. used to be 6. Mr. Brown _______go to bed late, but now he ______going to bed early. A. used to, used to B. used to, is used to C. is used to, used to D. is used to, is used to 7. The knife is _______bread. A. used to cut B. used to cutting C. use to cut D. used for cut 8. He used to ________in the sun, but now he is sued to __________at night. A. read, read B. reading, read C. read, reading D. reading, reading 9. This kind of cloth is used ______dress. A. to making B. to make C. to be made D. making 10. How does Jack usually go to school? —He ___ride a bike, but now he ___there to lose weight. A. used to, is used to walk B. was used to, is used to walking C. was used to, is used to walk C. used to, is used to walking 11. My grandpa ________a worker, but now he has retired. A. used to be B. use to be C. is D. used to have 12. We _________in this pool when we were young, but now it _____fish. A. are used to swim, used to B. are used to swimming, is used to keep. C. used to swim, used to keep D. used to swim, is used for keeping 二.翻译 1.我父亲过去常在这条河里捉鱼。 My father ________ ________ ______fishes in the river. 2. ——你曾经当过老师吗?——是的,当过。但我以前没教过英语。 ——________you ________ _________ ________a teacher? ——Y es, I _______. But I ______ ________________teach English. 3. 过去这里有一家电影院。 There _______ ______ ______ a cinema here. 4. 他过去常工作到深夜。 He _________ __________ _______late at night.

C++ #pragma code_seg用法

#pragma code_seg 格式如: #pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) 该指令用来指定函数在.obj文件中存放的节,观察OBJ文件可以使用VC自带的dumpbin命令行程序,函数在.obj文件中默认的存放节为.text节,如果code_seg 没有带参数的话,则函数存放在.text节中。 push (可选参数)将一个记录放到内部编译器的堆栈中,可选参数可以为一个标识符或者节名 pop(可选参数)将一个记录从堆栈顶端弹出,该记录可以为一个标识符或者节名identifier(可选参数)当使用push指令时,为压入堆栈的记录指派的一个标识符,当该标识符被删除的时候和其相关的堆栈中的记录将被弹出堆栈 "segment-name" (可选参数)表示函数存放的节名 例如: //默认情况下,函数被存放在.text节中 void func1() {// stored in .text } //将函数存放在.my_data1节中 #pragma code_seg(".my_data1") void func2() {// stored in my_data1 } //r1为标识符,将函数放入.my_data2节中 #pragma code_seg(push, r1, ".my_data2") void func3() {// stored in my_data2 } int main() { } 例如 #pragma code_seg(“PAGE”) 作用是将此部分代码放入分页内存中运行。 #pragma code_seg() 将代码段设置为默认的代码段 #pragma code_seg("INIT") 加载到INIT内存区域中,成功加载后,可以退出内存

used to do的用法

used to do的用法 张瑛2015.11 used to do意为“曾经是;过去常常”,表示过去存在的状态,或过去经常做某事而现在不做了,只用于一般过去时。其在陈述句、一般疑问句和反意疑问句中的用法如下: 一、陈述句 1. 在肯定句中,used没有人称和数的变化。例如: My granny used to be a history teacher. 我奶奶过去是一位历史教师。 He used to go to work by bus. 他过去常常坐公共汽车去上班。 2. 在否定句中,used to do有两种句式: A. 主语+ did not use to + 动词原形...。例如: He didn’t use to live here. 他过去不住在这儿。 B. 主语+ used not to + 动词原形...。例如: He usedn’t to smoke. 他过去不吸烟。 二、一般疑问句 在一般疑问句中,used to do有两种句式: A. Did + 主语+ use to + 动词原形...?。例如: Did he use to spend much time playing computer games? 他过去常花很多时间玩电脑游戏吗? B. Used + 主语+ to + 动词原形...? 例如: Used he to go to school on foot? 他过去常步行上学吗?

三、反意疑问句 在反意疑问句中,used to do也有两种句式: A. 陈述句+ used(n’t) + 主语?。例如: He used to like eating hot food, usedn’t he? 他过去爱吃辣的食物,对不对? He usedn’t to have curly hair, used he? 他过去没留卷发,对吗? B. 陈述句+ did(n’t) + 主语?。例如: There used to be an old tree behind my house, didn’t there? 过去在我家房子后面有一棵老树,对不对? Peter used to walk to school, didn’t he? 彼得过去步行上学,对不对? 注:1. used to do sth.可用于各种人称,表示过去存在但现在已经停止的情况或习惯。例如: He used to go home by bike. 他过去常常骑自行车回家。The river used to be clean. 这条河以前是干净的。 2. be used to + n. / doing sth. 意为“习惯于…… / 做某事”。例如: I’m not quite used to the weather here yet. 我还不太习惯这里的天气。 He is used to traveling by train. 他习惯坐火车旅行。 3. be used to do sth. 意为“被用来做某事”。例如:

初中英语usedto用法专题辅导

GRAMMAR初中英语used to 用法 【例】My uncle used to go to work on foot. 我叔叔过去常常步行去上班。 总结:used to意为“过去常常”, 暗指现在已经不存在的动作或状态, 后接动词原形。 句式 【练习】按要求改写句子。 1. I used to be afraid of the snakes. (改为否定句) I to be afraid of the snakes. 2. He used to be really friendly. (改为一般疑问句) he to be really friendly? 3. Did you use to play soccer after school?(作否定回答) No, . 4. I used to go to school by bus. (对划线部分提问) you to go to school? 5. They used to play basketball on the playground. (改为反意疑问句) They used to play basketball on the playground, ? 【重点提示】 1. 否定句 used to的否定式通常为didn’t use to。如: She didn’t use to have long hair. 2. 一般疑问句 含有used to的句子变为一般疑问句时, 可用“助动词Did+主语+use to do sth. ?”结构。肯定回答用Yes, sb. did;否定回答用No, sb. didn’t。如: —Did you use to play the piano? —Yes, I did. /No, I didn’t. 3. 特殊疑问句 含有used to的特殊疑问句的结构为“疑问词+助动词did+主语+use to do...?”。如:—What did you use to do? —I used to collect stamps. 4. 反意疑问句 如果陈述部分含有used to, 附加疑问部分通常使用助动词did来引导。如: The house used to be a shop, didn’t it? 辨析 【练习】根据句意, 选择合适的短语, 并用其正确形式填空。 used to/be used to 6. The big box hold books and magazines. 7. He send e-mails to me, but he doesn’t this year. 8. My grandpa going for a walk after dinner. 9. The students swim on weekends, did they? 10. I getting up early. 【重点提示】 1. be(get, become)used to doing sth. 意为“习惯于做某事”如: She has been used to living here. 她已经习惯住在这里了。 2. be used to do sth. 意为“被用于做某事”。如: Wood can be used to make paper. 木头能用来造纸。

C++ #pragma预处理命令

#pragma预处理命令 #pragma可以说是C++中最复杂的预处理指令了,下面是最常用的几个#pragma 指令: #pragma comment(lib,"XXX.lib") 表示链接XXX.lib这个库,和在工程设置里写上XXX.lib的效果一样。 #pragma comment(linker,"/ENTRY:main_function") 表示指定链接器选项/ENTRY:main_function #pragma once 表示这个文件只被包含一次 #pragma warning(disable:4705) 表示屏蔽警告4705 C和C++程序的每次执行都支持其所在的主机或操作系统所具有的一些独特的特点。例如,有些程序需要精确控制数据存放的内存区域或控制某个函数接收的参数。#pragma为编译器提供了一种在不同机器和操作系统上编译以保持C和C++完全兼容的方法。#pragma是由机器和相关的操作系统定义的,通常对每个编译器来说是不同的。 如果编译器遇到不认识的pragma指令,将给出警告信息,然后继续编译。Microsoft C and C++ 的编译器可识别以下指令:alloc_text,auto_inline,bss_seg,check_stack,code_seg,comment,component,conform,const_seg,data_seg,deprecated,fenv_access,float_control,fp_contract,function,hdrstop,include_alias,init_seg,inline_depth,inline_recursion,intrinsic,make_public,managed,message,omp,once,optimize,pack,pointers_to_members,pop_macro,push_macro,region, endregion,runtime_checks,section,setlocale,strict_gs_check,unmanaged,vtordisp,warning。其中conform,init_seg, pointers_to_members,vtordisp仅被C++编译器支持。 以下是常用的pragma指令的详细解释。 1.#pragma once。保证所在文件只会被包含一次,它是基于磁盘文件的,而#ifndef 则是基于宏的。

used to的用法小结

used to的用法小结 1.used to do sth.表示“过去常常做某事”,将过去和现在对比,暗示现在不做了。to为动词不定式符号,后接动词原形。如: He used to go to school at six o'clock.他过去常常六点去上学。 2.used to do sth.的否定形式 主语+usedn't to do sth.或主语+didn't use to do sth.如: He used to play computer games all day.他过去常常整天玩电脑游戏。 →He usedn't to play computer games all day. =He didn't use to play computer games all day.他过去不常整天地玩电脑游戏。 【注意】usedn't=used not 3.used to do的疑问句形式及其答语 (1)Used+主语+to do…? 回答:Yes,https://www.sodocs.net/doc/758701445.html,ed to./No,https://www.sodocs.net/doc/758701445.html,edn't to.如: Tom used to watch TV.→Used Tom to watch TV? Yes,he used to./No,he usedn't to. (2)Did+主语+use to do…? 回答:Yes,sb.did./No,sb.didn't.如: I used to do homework after school.→Did you use to do homework after school? Yes,I did./No,I didn't. 4.used to do的反意疑问句形式也有两种,类似于否定句形式。如: —They used to see English movies on Sundays,usedn't they?/didn't they? —Yes,they used to./No,they usedn't to.或Yes,they did./No,they didn't. 5.used to也可用于there be结构,表示“过去常有”。如: There used to be a meeting every Monday morning last month.上个月每个星期一上午总要开会。 6.get/be used to (doing) sth.习惯于(做)某事;use sth.to do sth.用……做某事;be used to do sth.被用来做某事;be used for (doing) sth.被用来做某事;be used by 被……所用。 语法精练 Ⅰ.用括号内所给单词的适当形式填空。 1.My little brother used (play) ping-pong. 2.I'm used to (get) up early. 3.Wood is used (make)desks,chairs,tables and so on. 4.you (use) to be short?

beused常见结构以及用法、例题、练习题

be used 常见结构以及典型例题练习题 1.be used to = become used to 习惯于(做)...... to 在这里是介词,后接名词、代词、动名词形式 eg. I’m not quite used to the weather here. 我还不太习惯这儿的天气。 2.be used for + 动名词形式、be used to do 被用来做某事 eg. A stamp is used for sending letters. 邮票用来寄信。 3.be used as 被当做......来使用 eg. English is used as their first language. 英语被用作他们的第一语言。 4.be used by 被......使用 eg. These books can be used by the students aga in. 这些书能够被学生们重新利用。 https://www.sodocs.net/doc/758701445.html,ed to do 过去常常做某事

eg. He used to get up early. 她过去习惯于早起。 习题 1. The pen ____________ writing. 2. He ____________ live in England, but now he lives in . My father _____________ drin king coffee after dinner. 4. I’ve never known that it can ___________ __ save lives. 5. English _____________ a foreign language i n China. 6. Tractors _____________ the farmers. 7. They _____________ (read) English for half an hour every morning. 8. There _____________ (be) a quiet village. 9. I think you will _____________ (live) in the countryside.

#pragma data code ICCAVR的使用

#pragma data:code 在Keil中为了节省数据存储器的空间,通过“code”关键字来定义一个数组或字符串将被存储在程序存储器中: uchar code buffer[]={0,1,2,3,4,5}; uchar code string[]="Armoric" ; 而这类代码移值到ICCAVR上时是不能编译通过的。我们可以通过"const" 限定词来实现对存储器的分配: #pragma data:code const unsigned char buffer[]={0,1,2,3,4,5}; const unsigned char string[]="Armoric"; #pragma data:data 注意: 《1》使用ICCAVR6.31时,#pragma data :code ;#pragma data:data ; 这些语法时在"data:cod"、"data:data"字符串中间不能加空格,否则编译不能通过。 《2》const 在ICCAVR是一个扩展关键词,它与ANSIC标准有冲突,移值到其它的编译器使用时也需要修改相关的地方。 在ICCAVR中对数组和字符串的五种不同空间分配: const unsigned char buffer[]={0,1,2,3,4,5}; //buffer数组被分配在程序存储区中 const unsigned char string[]="Armoric" ; //stringp字符串被分配在程序存储区中 const unsigned char *pt //指针变量pt被分配在数据存储区中,指向程序存储区中的字符类型数据 unsigned char *const pt //指针变量pt被分配在程序存储区中,指向数据存储区中的字符类型数据 const unsigned char *const pt //指针变量pt被分配在程序存储区,指向程序存储区中的字符类型数据 unsigned char *pt //指针变量pt被分配在数据存储区中,指向数据存储区中的数据 请问#pragma data:code和#pragma data:data是什么意思? 前者表示:随后的数据将存贮在程序区,即FLASH区,此区只能存贮常量,比如表格之类。

pragma的用法

#pragma的用法 在所有的预处理指令中,#Pragma 指令可能是最复杂的了,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义, 编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。 其格式一般为: #pragma para。其中para为参数,下面来看一些常用的参数。 1)message 参数 message参数是我最喜欢的一个参数,它能够在编译信息输出窗口中输出相应的信息,这对于源代码信息的控制是非常重要的。其使用方法为: #pragma message("消息文本") 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。 当我们在程序中定义了许多宏来控制源代码版本的时候,我们自己有可能都会忘记有 没有正确的设置这些宏, 此时我们可以用这条指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏, 可以用下面的方法: #ifdef _X86 #pragma message("_X86 macro activated!") #endif 我们定义了_X86这个宏以后,应用程序在编译时就会在编译输出窗口里显示"_86 macro activated!"。 我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了。 (2)另一个使用得比较多的pragma参数是code_seg 格式如: #pragma code_seg( ["section-name" [, "section-class"] ] ) 它能够设置程序中函数代码存放的代码段,当我们开发驱动程序的时候就会使用到 它。 (3)#pragma once (比较常用) 只要在头文件的最开始加入这条指令就能够保证头文件被编译一次,这条指令实际上 在VC6中就已经有了, 但是考虑到兼容性并没有太多的使用它。 (4)#pragma hdrstop 表示预编译头文件到此为止,后面的头文件不进行预编译。BCB可以预编译头文件以 加快链接的速度, 但如果所有头文件都进行预编译又可能占太多磁盘空间,所以使用这个选项排除一些头文

stm32中使用#pragma pack(非常有用的字节对齐用法说明)

#pragma pack(4) //按4字节对齐,但实际上由于结构体中单个成员的最大占用字节数为2字节,因此实际还是按2字节对齐 typedef struct { char buf[3];//buf[1]按1字节对齐,buf[2]按1字节对齐,由于buf[3]的下一成员word a是按两字节对齐,因此buf[3]按1字节对齐后,后面只需补一空字节 word a; //#pragma pack(4),取小值为2,按2字节对齐。 }kk; #pragma pack() //取消自定义字节对齐方式 对齐的原则是min(sizeof(word ),4)=2,因此是2字节对齐,而不是我们认为的4字节对齐。 这里有三点很重要: 1.每个成员分别按自己的方式对齐,并能最小化长度 2.复杂类型(如结构)的默认对齐方式是它最长的成员的对齐方式,这样在成员是复杂类型时,可以最小化长度 3.对齐后的结构体整体长度必须是成员中最大的对齐参数的整数倍,这样在处理数组时可以保证每一项都边界对齐 补充一下,对于数组,比如: char a[3];这种,它的对齐方式和分别写3个char是一样的.也就是说它还是按1个字节对齐. 如果写: typedef char Array3[3]; Array3这种类型的对齐方式还是按1个字节对齐,而不是按它的长度. 不论类型是什么,对齐的边界一定是1,2,4,8,16,32,64....中的一个. 声明: 整理自网络达人们的帖子,部分参照MSDN。 作用: 指定结构体、联合以及类成员的packing alignment; 语法: #pragma pack( [show] | [push | pop] [, identifier], n ) 说明: 1,pack提供数据声明级别的控制,对定义不起作用; 2,调用pack时不指定参数,n将被设成默认值; 3,一旦改变数据类型的alignment,直接效果就是占用memory的减少,但是performance会下降; 语法具体分析: 1,show:可选参数;显示当前packing aligment的字节数,以warning message的形式被显示; 2,push:可选参数;将当前指定的packing alignment数值进行压栈操作,这里的栈是the internal compiler stack,同时设置当前的packing alignment为n;如果n没有指定,则将当前的packing alignment数值压栈; 3,pop:可选参数;从internal compiler stack中删除最顶端的record;如果没有指定n,则当前栈顶record即为新的packing alignment 数值;如果指定了n,则n将成为新的packing aligment数值;如果指定了identifier,则internal compiler stack中的record都将被pop 直到identifier被找到,然后pop出identitier,同时设置packing alignment数值为当前栈顶的record;如果指定的identifier并不存在于internal compiler stack,则pop操作被忽略; 4,identifier:可选参数;当同push一起使用时,赋予当前被压入栈中的record一个名称;当同pop一起使用时,从internal compiler stack 中pop出所有的record直到identifier被pop出,如果identifier没有被找到,则忽略pop操作; 5,n:可选参数;指定packing的数值,以字节为单位;缺省数值是8,合法的数值分别是1、2、4、8、16。 重要规则: 1,复杂类型中各个成员按照它们被声明的顺序在内存中顺序存储,第一个成员的地址和整个类型的地址相同; 2,每个成员分别对齐,即每个成员按自己的方式对齐,并最小化长度;规则就是每个成员按其类型的对齐参数(通常是这个类型的大小)和指定对齐参数中较小的一个对齐; 3,结构体、联合体或者类的数据成员,第一个放在偏移为0的地方;以后每个数据成员的对齐,按照#pragma pack指定的数值和这个数据成员自身长度两个中比较小的那个进行;也就是说,当#pragma pack指定的值等于或者超过所有数据成员长度的时候,这个指定值的大小将不产生任何效果; 4,复杂类型(如结构体)整体的对齐是按照结构体中长度最大的数据成员和#pragma pack指定值之间较小的那个值进行;这样当数据成员为复杂类型(如结构体)时,可以最小化长度; 5,复杂类型(如结构体)整体长度的计算必须取所用过的所有对齐参数的整数倍,不够补空字节;也就是取所用过的所有对齐参数中最大的那个值的整数倍,因为对齐参数都是2的n次方;这样在处理数组时可以保证每一项都边界对齐; 对齐的算法:由于各个平台和编译器的不同,现以本人使用的gcc version 3.2.2编译器(32位x86平台)为例子,来讨论编译器对struct 数据结构中的各成员如何进行对齐的。 在相同的对齐方式下,结构体内部数据定义的顺序不同,结构体整体占据内存空间也不同,如下: 设结构体如下定义: struct A { int a; //a的自身对齐值为4,偏移地址为0x00~0x03,a的起始地址0x00满足0x00%4=0;

used to do的一些区别

used to do、be used to do与be used to doing sth.的用法详解used to do 过去常常做某事 be used to doing 习惯于做某事 be used to do sth 被用来做某事 1. used to的一般疑问句有两种构成方法: 1)将used提前至句首,结构为:Used + 主语+ to do sth...? 2)将did提前至句首,结构为:Did + 主语+ use to do sth...? 例如: Used he to get up early? = Did he use to get up early? 2. used to的反义疑问句有两种构成方法,例如: 1)He used to smoke,didn't he? 2)They usedn't to like opera,did they? 3.同样,其否定句也有两种构成方式: 1)直接在used后面加上not,也可一起缩写成usedn't. 结构为:主语+ used not to do sth... 或主语+ usedn't to do sth... 2)借助于助动词didn't,其结构为: 主语+ didn't use to do sth.... 例如: He used not to get up early. = He usedn't to get up early. = He didn't use to get up early. 4、be(get,become)used to结构在意义上相当于accustomed to“习惯于”,从形态上看,used是个分词型形容词,to是介词,因此后面只能跟名词、代词或动名词。例如: 1)They got used to living in the countryside.他们已习惯于住在农村。 2)I've got used to being a vegetarian.我已经习惯吃素食。 3)He is used to hard work.他习惯于艰苦工作。 5、be used to表示“习惯于某事”的状态,而get used to则表示由“不习惯”到“习惯于”这一动态的过程,意思是:“(变得)习惯于”;“开始习惯于”。试比较: He was used to the cold weather after he lived there for two years. 在那里住两年后,他已习惯了寒冷的天气。 I think it is a bit difficult for you to get used to the humid weather here. 我想,让你习惯于这里潮湿而炎热的天气有点困难。 You'll soon get used to living in the country. 很快你就会习惯于住在乡下了。 6、当主语是物的时候是指被用来做某事,be used to是动词use的被动语态,在这种结构里,to是不定式符号。例如: A metal bar was used to force the door open. 用金属棒把门撬开。

语法讲解(used to的用法)同步练习

语法讲解(used to的用法)同步练习 (答题时间:15分钟) Ⅰ. 单项选择 1. I ________ frustrated when I wasn’t sure of the correct answer. A. may be B. used to C. used to be D. use to be 2. When I was a child, I used to _________ chocolate. A. liking B. like C. liked D. likes 3. ___________ work in Microsoft? A. Did you used to B. Did you use to C. Do you used to D. Do you use to 4. Where ___________ live before you came here? A. did you used to B. did you use to C. use he to D. he used to 5. My father is used to _______at weekends. A. fish B. fishing C. fishes D. fished Ⅱ. 句型转换 1. Ann used to concentrate more on clothes than studies. (改为否定句) Ann ________ ________ to concentrate more on clothes than studies. 2. I used to have noodles for dinner. (改为一般疑问句并作肯定或否定回答) —________ you _______ ________have noodles for dinner? —Yes, I _________. — No, I _________. 3. The boy liked ice cream in the past. He doesn’t eat it now. (改为同义句) The boy ______ ______ ______ice cream. 4. Her sister used to be very short. (对划线部分提问) _________ _______her sister ______ _____ ________ ________? 5. He used to work late at night. (对划线部分提问) ______ ______ he _____ _____ ______ at night?

#pragma指令用法汇总和解析

#pragma指令用法汇总和解析 一. message 参数。 message 它能够在编译信息输出窗 口中输出相应的信息,这对于源代码信息的控制是非常重要的。其使用方法为: #pragma message(“消息文本”) 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。 当我们在程序中定义了许多宏来控制源代码版本的时候,我们自己有可能都会忘记有没有正确的设置这些宏,此时我们可以用这条 指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏可以用下面的方法 #ifdef _X86 #pragma message(“_X86 macro activated!”) #endif 当我们定义了_X86这个宏以后,应用程序在编译时就会在编译输出窗口里显示“_ X86 macro activated!”。我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了 二. 另一个使用得比较多的#pragma参数是code_seg。格式如: #pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) 该指令用来指定函数在.obj文件中存放的节,观察OBJ文件可以使用VC自带的dumpbin命令行程序,函数在.obj文件中默认的存放节 为.text节 如果code_seg没有带参数的话,则函数存放在.text节中 push (可选参数) 将一个记录放到内部编译器的堆栈中,可选参数可以为一个标识符或者节名 pop(可选参数) 将一个记录从堆栈顶端弹出,该记录可以为一个标识符或者节名 identifier (可选参数) 当使用push指令时,为压入堆栈的记录指派的一个标识符,当该标识符被删除的时候和其相关的堆栈中的记录将被弹出堆栈 "segment-name" (可选参数) 表示函数存放的节名 例如: //默认情况下,函数被存放在.text节中 void func1() { // stored in .text } //将函数存放在.my_data1节中 #pragma code_seg(".my_data1") void func2() { // stored in my_data1 } //r1为标识符,将函数放入.my_data2节中 #pragma code_seg(push, r1, ".my_data2") void func3() { // stored in my_data2 } int main() { } 三. #pragma once (比较常用) 这是一个比较常用的指令,只要在头文件的最开始加入这条指令就能够保证头文件被编译一次 四. #pragma hdrstop表示预编译头文件到此为止,后面的头文件不进行预编译。

相关主题