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
Why is packet switching important? Give at least two reasons. Packet switching is significant due to the following two purposes: 1. A sender and the receiver require coordin

Convert the decimal number 430 to Excess-3 code ? Ans. Excess  3  is  a  digital  code  acquired  from  adding  3  to  every  decimal  digit  and  after that converting the res

What is parsing? The target of parsing is to find out the syntactic validity of a source string. A tree is built for use through subsequent phase of compiler, if the string is

Multiprogramming is a rapid switching of the CPU back and forth among processes.

Explain non-adapting routing. Systems which do not implement adaptive routing are explained as using non-adapting or static routing, which routes by a network are explained by

Power pc h bus

Rounding off of values can be carried out using the write statement. Yes, Rounding off value can be out by using the write statement.

Search mechanisms in Prolog We can utilize this simple Prolog program to describe how Prolog searches: president(X) :- first_name(X, georgedubya), second_name(X, bush). p

Digital Signature is Software to recognize signature

What is USB USB (UNIVERSAL SERIAL BUS) is intended to connect peripheral devices like mouse, keyboards, modems and sound cards to microprocessor through a serial data path and