Computer Science, asked by abhieswari2, 5 months ago

write a general format of single character input and output function​

Answers

Answered by 10thclass71
1

Explanation:

write a general format of single character input and output functionThe C language is accompanied by a collection of library functions which includes a number of input/output functions.These functions are used to permit the transfer of information between the computer and the standard input/output device. The basic input/output functions are getchar, putchar, puts, scanf and printf. The first two functions, getchar and putchar, are used to transfer single characters. The next function puts is used to output strings, and the last two functions, scanf and printf, permit the transfer of single characters, numerical values and strings.

An input/output function can be accessed from anywhere within a program simply by writing the function name, followed by a list of arguments enclosed in parentheses. The arguments represent data items that are sent to the function. Some input/output functions do not require arguments, though the empty parentheses must still appear.

The names of those functions that return data items may appear within expressions, as though each function reference were an ordinary variable (eg, c=getchar();), or they may be referenced as separate statements (eg, scanf(...);). Some functions do not return any data items. Such functions are referenced as though they were separate statements (eg, putchar(...);).

C includes a collection of header files that provide necessary information in support of the various library functions. Each file generally contains information in support of a group of related library functions. These files are entered into the program via an #include statement at the beginning of the program. As a rule, the header file required by the standard input/output library functions is called stdio.h.

Single Character Input: the getchar Function

The getchar function is a part of the standard C input/output library. It returns a single character from a standard input device (typically a keyboard). The function does not require any arguments, though a pair of empty parentheses must follow the word getchar.

In general, a function reference would be written as:

character variable = getchar( );

where character variable refers to some previously declared character variable.

If an end-of-file condition is encountered when reading a character with the getchar function, the value of the symbolic constant EOF will automatically be returned. (This value will be assigned within the stdio.h file. Typically, the EOF will be assigned the value -1). The detection of EOF in this manner offers a convenient way to detect an end of file, whenever and wherever it may occur. Appropriate corrective action may then be taken.

The getchar function can also be used to read multi-character strings by reading one character at a time within a multi-pass loop

Similar questions