问题 单项选择题

如果需要打开一个已经存在的非空文件“Demo”进行修改,下面选项中正确的是( )。

A.fp=fopen("Demo",'r');

B.fp=fopen("Demo","ab+");

C.fp=fopen("Demo","w+");

D.fp=fopen("Demo","r+");

答案

参考答案:D

解析: 此题考查文件打开方式对文件操作的影响。由于打开文件进行修改,可见选项A)是错误的,因为此种方式打开时,只能读,不能写,当然无法修改;选项B)是以追加方式“ab+”打开文件读写,以这种方式打开时,新写入的数据只能追加在文件原有内容之后,但可以对以前的数据读出。换言之,“ab+”或“a+”方式打文件后,对于写操作,文件指针只能定位在文件的原有内容之后,但对于读操作,文件指针可以定位在全文件范围内,可见,按此种方式打开文件不能实现文件内容的修改;选项C)以“w+”方式打开文件,此时,原文件中已存在的内容都被清除,但新写入文件的数据可以被再次读出或再次写入,故也不能实现对文件的修改。只有以“r+”方式打开文件时,才允许将文件原来数据读出,也允许在某些位置上再写入,从而实现对文件的修改。

阅读理解

阅读理解

     Do you remember piling up building blocks (积木) when you were younger?In order for a great

structure to be created,you needed skill,patience,hard work,and the right blocks.To build a healthy and

happy life,you need skill,patience,hard work,and the right blocks.In life,though,these blocks,or tools,are

called life skills.

     No one wants to feel frustrated.No one wants to feel sick.No one wants to fight all the time with friends

or family.When these issues come up,though,life skills can help you deal with and improve the situation.

     Do you remember the six components of health?They are physical,emotional,social,mental,spiritual,and

environmental.Life skills can help improve these areas individually or,sometimes,together.It just takes

practice.So what are the life skills?

     First of all,an individual should assess his health.Doing this helps the person decide on his current state

of wellbeing and pick the actions and behaviors that will improve his health.

     Second,a person should try to communicate effectively.When a person can clearly state his feelings and

listen effectively as well,relationships with others can improve.

     Third,an individual should practice wellness.This means the person is trying to choose nutritious meals,

avoid unhealthy behaviors,and get enough sleep.

     Fourth,________.Each person will experience difficult situations.Each person experiences anger or

depression at some point in his life.To build a healthy life,though,a person works through the situation.

    Fifth,a person needs to be a wise consumer.A consumer buys products.A wise consumer makes healthy

decisions when buying products and services.

1.The author talks about piling up building blocks in the first paragraph to________.

A.show it is a difficult task

B.compare it with building a healthy life

C.explain how to create a great structure

D.tell readers the six components of health

2.The underlined word "wellness" in the passage most probably means "________".

A.having a lot of money

B.the state of being healthy

C.being content with what one has

D.being not easily upset or excited

3.Which of the following sentences can be used to fill in the blank?

A.a person should learn from failure

B.a person should work hard all his life

C.a person may have troubles every now and then

D.an individual must try to deal with troubles effectively

判断题