How putchar function is used within a c program, Computer Engineering

How putchar function is used within a C Program ?

The following program reads each character in the first line of input entered at the terminal's keyboard. It uses putchar to display, on the terminal's screen, each character from the line.

#include

int c;

main()

{

puts("Enter a line of input.");

while ( (c = getchar()) != '\n' ) /* Look for newline */

{

putchar(c);

}

putchar('\n');

}

putchar writes one character to the standard output file, stdout. But getchar

Reads and returns the next character from the standard input file, stdin.

Syntax

#include

int getchar(void);

The getchar macro reads the next character from the preopened file pointed to by stdin. The file pointed to by stdin is usually associated with the terminal's keyboard. If the file is at end- of-file, getchar sets the end-of-file indicator for stdin. If a read error occurs, the macro sets the error indicator associated with stdin. If the file is at end-of-file or a read error occurs, getcharsets the external variables errno and os_errno to the appropriate error code number.

The getchar macro returns an integer value representing the next character from stdin. If a read error occurs or the file is at end-of-file, getchar returns EOF.

 

Posted Date: 6/14/2013 6:24:15 AM | Location : United States







Related Discussions:- How putchar function is used within a c program, Assignment Help, Ask Question on How putchar function is used within a c program, Get Answer, Expert's Help, How putchar function is used within a c program Discussions

Write discussion on How putchar function is used within a c program
Your posts are moderated
Related Questions
composition of two shm in right angles to each other to havingg time period in the ratio 1:2

What are preprocessor directives? Preprocessor directives: These are the commands given to a program called as pre-processor that processes the source code before it passes by

Extend task 1 so that it now supports a memory buffer of limited size. Provide the same functionality as task 1 except now make the server work with a limited buffer size. Like

what is time out based schemes in concurrency control

What is the use of fork and exec system calls?  Fork is a system call by which a new process is formed. Exec is also a system call, which is used after a fork by one of the two

Explain about unix file system architecture

How can we change almost any algorithm to have a good best case running time? Check whether the input constitutes an input at the very starting Or else run the original algo

Write the HTML code to accomplish the web page to insert an image onto a page using good.gif as image and having "welcome" as the ALT text. The HTML code to accomplish the web

Technology Enablers - Information System The progression described above has been enabled by five main factors: Increases in processing capability allowing smaller and

Give example of bus and memory transfer For example, the read operation for transfer of a memory unit M from address register AR to another data register DR can be illustrated