What word in the text is used instead of buffer

1. Name
some types of devices that use ‘computers on a chip’.

2. What uses of handheld
computers are mentioned in the text?

3. What are the benefits of
using computers with the following items?

a Security systems

b Cars

c Phones

4. What smart devices are
mentioned in the text?

5. What are smart cards used
for?

6. What are the advantages
of multimedia?

7. What can medical expert
systems do?

8. How can computers help
the disabled?

9. What types of computing
systems are made available to people in remote locations using
electronic classrooms or boardrooms?

10. What aspects of computing
can people power determine?

The ability of tiny computing
devices to control complex operations has transformed the way many
tasks are performed, ranging from scientific research to producing

5
consumer products. Tiny ‘computers on a chip’ are used in medical
equipment, home appliances, cars and toys. Workers use handheld
computing devices to collect data at a customer site, to generate
forms, to control

10
inventory, and to serve as desktop organisers.

Not only is computing
equipment getting smaller, it is getting more sophisticated.
Computers are part of many machines and devices that once required
continual human

15
supervision and control. Today, computers in security systems result
in safer environments, computers in cars improve energy efficiency,
and computers in phones provide features such as call forwarding,
call monitoring, and

20
call answering.

These smart machines are
designed to take over some of the basic tasks previously performed by
people; by so doing, they make life a little easier and a little more
pleasant.

25
Smart cards store vital information such as health records, drivers’
licenses, bank balances, and so on. Smart phones, cars, and
appliances with built in computers can be programmed to better meet
individual needs.

30
A smart house has a built-in monitoring system that can turn lights
on and off, open and close windows, operate the oven, and more.

With small computing devices
available for

35
performing smart tasks like cooking dinner, programming the DVD
recorder, and controlling the flow of information in an organization,
people are able to spend more time doing what they often do best —
being creative. Computers

40
can help people work more creatively.

Multimedia systems are known
for their educational and entertainment value, which we call
‘edutainment’. Multimedia combines text with sound, video, animation,
and

45
graphics, which greatly enhances the interaction between user and
machine and can make information more interesting and appealing to
people. Expert systems software enables computers to ‘think’ like
experts.

50
Medical diagnosis expert systems, for example, can help doctors
pinpoint a patient’s illness, suggest further tests, and prescribe
appropriate drugs.

Connectivity enables computers
and software

55
that might otherwise be incompatible to communicate and to share
resources. Now that computers are proliferating in many areas and
networks are available for people to access data and communicate with
thers,

60
personal
computers are becoming

interpersonal PCs. They have
the potential to significantly improve the way we relate to each
other. Many people today telecommute -that is, use their computers to
stay in touch

65
with the office while they are working at home. With the proper
tools, hospital staff can get a diagnosis from a medical expert
hundreds or thousands of miles away. Similarly, the disabled can
communicate more

70
effectively with others using computers.

Distance learning and
videoconferencing are concepts made possible with the use of an
electronic classroom or boardroom accessible to people in remote
locations. Vast databases

75
of information are currently available to users of the Internet, all
of whom can send mail messages to each other. The information
superhighway is designed to significantly expand this interactive
connectivity so that

80
people all over the world will have free access to all these
resources.

People power is critical to
ensuring that hardware, software, and connectivity are effectively
integrated in a socially responsible

85
way. People — computer users and computer professionals — are the
ones who will decide which hardware, software, and networks endure
and how great an impact they will have on our lives. Ultimately
people power

90
must be exercised to ensure that computers are used not only
efficiently but in a socially responsible way.

B
Re-read the text to find the answers to these questions:

  1. Match
    the terms in Table A with the statements in Table B.

Table A

a
Edutainment

b Multimedia

c
Expert system

d
Telecommute

e
Information superhighway

Table B

I Software that enables
computers to ‘think’ like experts

II
Use computers to stay in touch with the office while working at
home

III
Internet system designed to provide free, interactive access to
vast resources for people all over the world

IV
Multimedia materials with a combination of educational and
entertainment content

V
A combination of text with sound, video, animation, and graphics

Mark
the following statements as True or False:

  1. Desktop
    organisers are programs that require desktop computers.

  2. Computers
    are sometimes used to monitor systems that previously needed human
    supervision.

  3. Networking
    is a way of allowing otherwise incompatible systems to communicate
    and share resources.

  4. The
    use of computers prevents people from being creative.

  5. Computer
    users do not have much influence over the way that computing
    develops.

Text
2
Cache
memory

A
Find
the answers to these questions in the following texts.

  1. What
    is one of the main causes of a PC not running at its highest
    potential speed?

  2. What
    word in the text is used instead of ‘buffer’?

  3. What
    device looks after cache coherency?

  4. What
    is the main alternative to ‘write-through cache’?

  5. When
    does a write-back cache write
    its
    contents
    back to main memory?

  6. When
    is data marked as ‘dirty’ in a write-back cache?

  7. What
    determines what data is replaced in a disk cache?

Most PCs
are held back not by the
speed of their main processor, but by the time it takes to move data
in and out of memory. One of the most important techniques for
getting around this

5
bottleneck is the memory cache.

The idea is to use a small
number of very fast memory chips as a buffer or cache between main
memory and the processor. Whenever the processor needs to read data
it looks in this cache

10
area first. If it finds the data in the cache then this counts as a
‘cache hit’ and the processor need not go through the more laborious
process of reading data from the main memory. Only if the data is not
in the cache does it need to access main

15
memory, but in the process it copies whatever it finds into the cache
so that it is there ready for the next time it is needed. The whole
process is controlled by a group of logic circuits called the cache
controller.

20
One of the cache controller’s main jobs is to look after ‘cache
coherency’ which means ensuring that any changes written to main
memory are reflected within the cache and vice versa. There are
several techniques for achieving this, the most obvious

25
being for the processor to write directly to both the cache and main
memory at the same time. This is known as a ‘write-through’ cache and
is the safest solution, but also the slowest.

The main alternative is the
‘write-back’ cache

30
which allows the processor to write changes only to the cache and not
to main memory. Cache entries that have changed are flagged as
‘dirty’, telling the cache controller to write their contents back to
main memory before using the space to

35
cache new data. A write-back cache speeds up the write process, but
does require a more intelligent cache controller.

Most cache controllers move a
‘line’ of data rather than just a single item each time they need to

40
transfer data between main memory and the cache. This tends to
improve the chance of a cache hit as most programs spend their time
stepping through instructions stored sequentially in memory, rather
than jumping about from one

45
area to another. The amount of data transferred each time is known as
the ‘line size’.

How
a Disk Cache Works

Disk caching works in
essentially the same way whether you have a cache on your disk
controller or you are using a software-based solution. The CPU
requests specific data from

5
the cache. In some cases, the information will already be there and
the request can be met without accessing the hard disk.

If the requested information
isn’t in the cache, the data is read from the disk along with a

10
large chunk of adjacent information. The cache then makes room for
the new data by replacing old. Depending on the algorithm that is
being applied, this may be the information that has been in the cache
the longest, or the

15
information that is the least recently used. The CPU’s request can
then be met, and the cache already has the adjacent data loaded in
anticipation of that information being requested next.

B
Re-read the

texts to find the answers to
these
questions.

  1. Match the terms in Table A
    with the statements in Table B.

Table A

a
Cache hit

b Cache controller

c
Cache coherency

d
Write-through cache

e
Write-back cache

f
Line size

Table B

I
The process of writing changes only to the cache and not to main
memory unless the space is used to cache new data

II
The amount of data transferred to the cache at any one time

III
The process of writing directly to both the cache and main memory
at the same time

IV
The processor is successful in finding the data in the cache

V
Ensuring that any changes written to main memory are reflected
within the cache and vice versa

VI
The logic circuits used to control the cache process

  1. Mark the following as True
    or False:

  1. Cache
    memory is faster than RAM.

  2. The
    processor looks for data in the main memory first.

  3. Write-through
    cache is faster than write-back cache.

  4. Write-back
    cache requires a more intelligent cache controller.

  5. Most
    programs use instructions that are stored in sequence in memory.

  6. Most
    cache controllers transfer one item
    of
    data at a time.

  7. Hardware
    and software disk caches work in much the same way.

Соседние файлы в папке СТУДЕНТАМ

  • #
  • #
  • #
  • #
  • #
  • #
  • #
  • #

PRODUCTS AVAILABLE

Hard disk drive.

Superfast 8 ms hard drive. Capacity ranges from 6 GB to 1 TB.

Iomega’s removable drives.

The Zip series uses 100 MB and 250 MB disks. In the nearer future it can replace the floppy disk as the portable storage medium.

The Jaz series can hold 2 GB cartridges. Ideal to back up hard disks.

CD-ROM drive.

Each CD disk holds 650 MB.

CD-Recordable drive.

Makes it possible to write data to CDs as well as read it.

Magneto-optical (MO) disk systems.

Erasable optical-magnetic 5.25″ cartridges with 5.2 GB of storage capacity. Can be erased and written on like a hard disk.

Rewritable 3.5″ floptical disks with a storage capacity of 1.3 GB.

DAT Data tape drive.

Digital audio tape drives to store computer data. Used for back-up purposes. Slow access. Huge amounts of information (about 10 GB).

Digital Video Disk-ROM drive.

Each DVD-ROM disk has a capacity of up to 17 GB, and can hold various full-screen movies. The drive can also read your CD-ROMs.
38. Notice how these terms are used in computing.

bit (b) a 0 or a 1 in the binary system

byte(B) a group of eight bits, e.g. 10101110

kilo (K) 210 (approximately a thousand)

mega (M) 220 (approximately a million)

giga (G) 230 (approximately a thousand million)
39. Now work in pairs, A and B. Fill in the gaps in this table as your partner dictates. Ask your partner to repeat if necessary.

Storage device Capacity Storage device Capacity
DVD

High density floppy Average hard disk

………………

………………

………………

CD-ROM

Large hard disk

Tape

………………….

………………….

………………….

Student A — Your data is on page 139.

Student B — Your data is on page 140.
Text 7 B

CACHE MEMORY

40. Find the answers to questions in the following text.

1. What is one of the main causes of a PC not running at its highest potential speed?

2. What word in the text is used instead of “buffer”?

3. What device looks after cache coherency?

4. What is the main alternative to “write-through cache”?

5. When does a write-back cache write its contents back to main memory?

6. When is data marked as “dirty” in a write-back cache?

7. What determines that data is replaced in a disk cache?
41. Skim the text, trying to understand what it is about. Time your reading. It is good if you can read it for minutes (70 words per minute).

cache coherency непротиворечивость, синхронизация

cache controller – контролер кэш-памяти

cache hit “попадание”, наличие нужных данных

cache miss – “непопадание”, отсутствие нужных данных

writethrough cache – кэш с прямой записью

write back cache – кэш с обратной записью

chunk – участок памяти, часть данных

disk caching – кэширование диска

cache line – строка данных кэша

to request – запрашивать, требовать

adjacent – смежный, примыкающий

anticipation — ожидание

vice versa наоборот

dirty — недействительный, измененный
Most PCs are held back not by the speed of their main processor, but by the time it takes to move data in and out of memory. One of the most important techniques for getting around this bottleneck is the memory cache.

The idea is to use a small number of very fast memory chips as a buffer or cache between main memory and the processor. Whenever the processor needs to read data it looks in this cache area first. If it finds the data in the cache then this counts as a “cache hit” and the processor need not go through the more laborious process of reading data from the main to memory. Only if the data is not in the cache does it need to access main memory, but in the process it copies whatever it finds into the cache so that it is there ready for the next time it is needed. The whole process is controlled by a group of logic circuits called the cache controller.

One of the cache controller’s main jobs is to look after “cache coherency” which means ensuring that any changes written to main memory are reflected within the cache and vice versa. There are several techniques for achieving this, the most obvious being for the processor to write directly to both the cache and main memory at the same time. This is known as a “write-through” cache and is the safest solution, but also the slowest.

The main alternative is the “write-back” cache which allows the processor to write changes only to the cache and not to main memory. Cache entries that have changed are flagged as “dirty”, telling the cache controller to write their contents back to main memory before using the space to cache new data. A write-back cache speeds up the write process, but does require a more intelligent cache controller.

Most cache controllers move a “line” of data rather than just a single item each time they need to transfer data between main memory and the cache. This tends to improve the chance of a cache hit as most programs spend their time stepping through instructions stored sequentially in memory, rather than jumping about from one area to another. The amount of data transferred each time is known as the “line size”.

Disk caching works in essentially the same way whether you have a cache on your disk controller or you are using a software-based solution. The CPU requests specific data from the cache. In some cases, the information will already be there and the request can be met without accessing the hard disk.

If the requested information isn’t in the cache, the data is read from the disk along with a large chunk of adjacent information. The cache then makes room for the new data by replacing old. Depending on the algorithm that is being applied, this may be the information that has been in the cache the longest, or the information that is the least recently used. The CPU’s request can then be met, and the cache already has the adjacent data loaded in anticipation of that information being requested next.
42. Match the terms in Table A with the statements in Table B.

Table A Table B
  1. Cache hit
  2. Cache controller
  3. Cache coherency
  4. Write-through cache
  5. Write-back cache
  6. Line size
  1. The process of writing changes only to the cache and not to main memory unless the space is used to cache new data.
  2. The amount of data transferred to the cache at any one time.
  3. The process of writing directly to both the cache and main memory at the same time.
  4. The processor is successful in finding the data in the cache.
  5. Ensuring that any changes written to main memory are reflected within the cache and vice versa.
  6. The logic circuits used to control the cache process.

43. Mark the following as True or False:

        1. Cache memory is faster than RAM.
        2. The processor looks for data in the main memory first.
        3. Write-through cache is faster than write-back cache.
        4. Write-back cache requires a more intelligent cache controller.
        5. Most programs use instructions that are stored in sequence in memory.
        6. Most cache controllers transfer one item of data at a time.
        7. Hardware and software disk caches work in much the same way.

44. Study this data about storage devices. Then complete the blanks in the following sentences comparing and contrasting the different types.

Device Read/Write Speed Media Capacity Media Removable Cost
Floppy disk Read and write Slow Very low Yes Low
Fixed hard disk Read and write Fast Very high No Medium
Removable hard disk Read and write Medium to fast High Yes Medium
CD-ROM Read only Medium High Yes Low
CD-R Recordable Slow High Yes Medium
CD-RW Read and write Medium High Yes Medium
CD-MO Read and write Medium High Yes High
DVD-ROM Read only Medium High Yes Medium
DVD-RAM Read and write Medium Very high Yes High
Magnetic Tape Read and write Very slow High Yes Medium

1. You can write to hard disks ………. optical disks.

2. Floppy disks have a ………. capacity …………. other devices.

3. CD-ROMs and floppy disks are ……….. low priced.

4. DVD-RAM has a ………. capacity ……….. other optical disks.

5. CD-ROMs cannot be re-recorded ………. some other optical disks can be.

6. ……… hard disks, you can read from and write to CD-MO drives.

7. ……… CD-ROMs, CD-Rs are recordable.

8. Magnetic tape is much ….. other devices.

9. ……. DVD-RAM and fixed hard disks have very high media capacity.

10. Floppy disks are cheap …… DVD-RAM is expensive.
Text 7C

READY FOR THE BAZILLON-BYTE DRIVE

45. Find the answers to these questions in the following text.

1. What is Currie Munce’s main aim?

2. How quickly did the possible areal density of hard disks increase in the 1990s?

3. How long does Munce think magnetic recording technology will continue to make, rapid advances in capacity?

4. What problem does he predict for magnetic storage?

5. What is the predicted limit for discrete bit magnetic storage capacity?

6. What storage technologies might replace current magnetic systems?

7. What is the advantage of holographic storage being three-dimensional?

8. What improvements are predicted due to the fast access rates and transfer times of holographic storage?

9. What is predicted to be the most important high capacity removable storage media in the next 10 years?

10. What method of software distribution is likely to replace optical disks?
Thinking about writing your memoirs — putting your life story down on paper for all eternity? Why not skip the repetitive strain injury and just capture your whole life on full-motion video, putting it all in a device the size of a sugar cube? It might not be as far off as you think.

Currie Munce, director of IBM’s Advanced HDD Technology Storage Systems Division, has one avowed goal: Build bigger storage. Recently Munce and his fellow Ph.Ds restored Big Blue’s lead in the disk space race with a new world record for areal (bit) density: 35.3 gigabits per square inch — roughly three times as dense as any drive shipping at press time.

During the 1990s, areal density doubled every 18 months, keeping pace with the transistor density gains predicted by Moore’s Law. But increasingly daunting technical challenges face those who would push the storage envelope further. “I think magnetic recording technology has another good 5 to 10 years,” says Munce. “After that, we’ll see substantial difficulties with further advances at the pace people are accustomed to.”

From here on, a phenomenon called superparamagnetism threatens to make densely-packed bits unstable. Provided that new developments continue to thwart superparamagnetic corruption, scientists speculate that the theoretical limit for discrete bit so recording is 10 terabits per square inch (1 terabit = 1,000 gigabits).

Approaching this limit will require new technologies. Two possible contenders are atomic force microscopy (AFM) and holographic storage. AFM would use a spinning plastic disk, perhaps inside a wristwatch, and a tiny, 10-micron cantilever with a 40-angstrom tip (an angstrom represents the approximate radius of an atom) to write data. In theory, AFM will allow densities of 300 to 400 gigabits per square inch.

While AFM is still in the lab, holographic storage is closer to reality. According to Rusty Rosenberger, optical program manager for Imation, “We are targeting a 5¼-inch disk with 125GB of storage and a 40MB-per-second transfer rate.” Future iterations of holographic systems should improve substantially.

The three-dimensional nature of holography makes it an appealing storage medium because so “pages” of data can be superimposed on a single volume — imagine transferring a whole page of text at once as opposed to reading each letter in sequence. Hans Coufal, manager of IBM’s New Directions in Science and Technology Research division, predicts that the fast access rates and transfer times of holographic storage will lead to improved network searches, video on demand, high-end servers, enterprise computing, and supercomputing.

Meanwhile, also-ran technologies are thriving. Tape, first used for data storage in 1951 with the UNIVAC I, has been revitalized by the corporate hunger for affordable archiving solutions. In the consumer arena, says Dataquest analyst Mary Craig, recordable CD-ROMs and DVDs will remain the dominant high-capacity removable storage media for the next decade. Despite their failure to match the areal density gains of hard disks, optical disks are cheap to produce, making them ideal for software distribution (until a mature digital rights management system facilitates online delivery). Finally, solid state options such as flash cards can’t yet match the pricing of hard disks at high capacities.

Further out, scientists salivate over the prospect of data manipulation and storage on an atomic level. Because consumer demand for capacity is lagging behind what technology can deliver, bringing new storage options to the masses will depend on seeing the need for more space.
46. Re-read the text to find the answers to those questions. Match the terms in Table A with the statements in Table B.

Table A Table B
1. Big Blue

2. Areal density

3. Moore’s Law

4. Superparamagnetis

5. Terabit

6. AFM

7. Angstrom

a. Atomic force microscopy;

b. The approximate radius of an atom;

c. IBM;

d. The data capacity of a storage device measured in bits per square inch;

e. Prediction that the number of transistors j that can be incorporated into a processor chip will double every 18 months;

f. A phenomenon that threatens to make densely packed bits unstable in magnetic storage devices;

g. One thousand gigabits.

47. Mark the following statements as True or False:

1. The development of AFM is more advanced than holographic storage.

2. The predicted maximum storage density of AFM is 400 gigabits per square inch.

3. Holography works in 3D.

4. UNIVAC I was the first computer to use tape storage devices.

5. Users want higher capacity storage devices than technology can provide.

What word in the text is used instead of buffer? перевод - What word in the text is used instead of buffer? русский как сказать

  • Текст
  • Веб-страница

What word in the text is used instead of buffer?

0/5000

Результаты (русский) 1: [копия]

Скопировано!

Какое слово в тексте используется вместо буфера?

переводится, пожалуйста, подождите..

Результаты (русский) 2:[копия]

Скопировано!

Какое слово в тексте используется вместо буфера?

переводится, пожалуйста, подождите..

Результаты (русский) 3:[копия]

Скопировано!

какие слова в тексте используется вместо буфера?

переводится, пожалуйста, подождите..

Другие языки

  • English
  • Français
  • Deutsch
  • 中文(简体)
  • 中文(繁体)
  • 日本語
  • 한국어
  • Español
  • Português
  • Русский
  • Italiano
  • Nederlands
  • Ελληνικά
  • العربية
  • Polski
  • Català
  • ภาษาไทย
  • Svenska
  • Dansk
  • Suomi
  • Indonesia
  • Tiếng Việt
  • Melayu
  • Norsk
  • Čeština
  • فارسی

Поддержка инструмент перевода: Клингонский (pIqaD), Определить язык, азербайджанский, албанский, амхарский, английский, арабский, армянский, африкаанс, баскский, белорусский, бенгальский, бирманский, болгарский, боснийский, валлийский, венгерский, вьетнамский, гавайский, галисийский, греческий, грузинский, гуджарати, датский, зулу, иврит, игбо, идиш, индонезийский, ирландский, исландский, испанский, итальянский, йоруба, казахский, каннада, каталанский, киргизский, китайский, китайский традиционный, корейский, корсиканский, креольский (Гаити), курманджи, кхмерский, кхоса, лаосский, латинский, латышский, литовский, люксембургский, македонский, малагасийский, малайский, малаялам, мальтийский, маори, маратхи, монгольский, немецкий, непальский, нидерландский, норвежский, ория, панджаби, персидский, польский, португальский, пушту, руанда, румынский, русский, самоанский, себуанский, сербский, сесото, сингальский, синдхи, словацкий, словенский, сомалийский, суахили, суданский, таджикский, тайский, тамильский, татарский, телугу, турецкий, туркменский, узбекский, уйгурский, украинский, урду, филиппинский, финский, французский, фризский, хауса, хинди, хмонг, хорватский, чева, чешский, шведский, шона, шотландский (гэльский), эсперанто, эстонский, яванский, японский, Язык перевода.

  • его книги всегда оказывают большое влиян
  • Before the operation
  • Service: International PriorityAmount: $
  • Твоя охота очень дорогая
  • 1. Today I want to tell you about my fla
  • Твоя охота очень дорогая
  • do you have any photos? im trying to sen
  • Твоя охота очень дорогая
  • ПУСТЬ ВСЕ БУДЕТ ХОРОШО
  • ossa sunt
  • ты прелесть
  • Твоя охота очень дорогая
  • What is main alternative to ‘write-throu
  • Special Offers I would like to receive e
  • ПУСТЬ ВСЕ БУДЕТ ХОРОШО
  • Type: MasterCard ending in 997Amount: $1
  • sternum, costa, vertebra femur ossa sunt
  • do you have any photos? im trying to sen
  • MY FAMILY AND ME Our family is neither b
  • заказ не пришел
  • Gaius est pater historiae iuris romani
  • courageous
  • заказ не пришел
  • nuclear famly состоит из родителей и дет

The problem of reading user input safely, limiting the input to a certain set of «allowed» inputs, while cleanly disregarding «disallowed» inputs, can be a surprisingly tricky one.

Also surprising, perhaps, is how poor a function scanf is for performing this task, and how difficult it is to solve the problem completely using any algorithm built around scanf.

You asked why this code didn’t «directly do it the easy way». By «the easy way» I assume you mean something like

scanf("%d", &choice);

The problem here is that, yes, it can be remarkably difficult to proceed correctly if the user types some non-numeric input.

There are two general avenues to take when trying to handle the possibility that the user types something wrong:

  1. Continue to call scanf("%d") to read the input, but then, try to patch things up if scanf fails. (Obviously the first step here is to check scanf‘s return value.)
  2. Read a line of input, as text, using something other than scanf. Then attempt to validate that line, and convert it to the desired form.

In my opinion, there is only one choice here, and it is #2. This answer will become far too long if I discuss all the reasons, but the bottom line is that approach #1 is futile. The scanf function has one virtue and one virtue only, and that is that a call like scanf("%d", &choice) is indeed very simple. But the error handling is almost useless. By the time you’ve built up a reasonable amount of error handling around it, the amount of work you’ll have had to do is about three times as much as for approach #2, and you still won’t have fully satisfactory results.

So most experienced C programmers will agree that #2 is the only viable approach in the long run. There’s a central question advising on good ways of doing input using something other than scanf.

The problem with the code you’ve posted, IMO, is that it manages to combine the worst of both worlds. It does try to read a line of input as text, then process it later, but the way it reads that line of input is with… the dreaded scanf! And despite trying to be careful in several other ways, this code doesn’t even check scanf‘s return value, so there are some classic problems (like premature EOF) that this code is still vulnerable to.

This code also contains a mysterious extra call to getchar, which is typical of scanf-using code, since stray newlines are almost always a problem.

This code also uses %[...], which is my least favorite scanf format. As I said, scanf‘s only virtue is simplicity, but a locution like "%[^n]" is anything but simple. Yes, I know what it does, but IMO it completely defeats the purpose of using scanf for dirt-simple (if less than robust) user input.

But, yes, the primary intent of writing the code this way is probably «so that if the user enters a character instead of a number, the code doesn’t malfunction». The code reads a line of text, as text, then attempts to convert the text to a number. You asked what the atoi function does with alphabetic input, and the answer is that (most of the time, anyway) it quietly returns 0. Since 0 isn’t a valid input, this code will reject it, so in that sense it works.

To improve this function, the first thing to do would be to replace the calls to scanf and getchar with fgets. The next thing to do would be to replace atoi with strtol. And then it wouldn’t be too bad.

Понравилась статья? Поделить с друзьями:
  • What word games com
  • What word game answers countries
  • What word follows a preposition
  • What word ends with low
  • What word eight letters