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.


int c;



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

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






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

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



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
The enableEvents() method is used to enable an event for a certain object. Normally, an event is enabled when a listener is added to an object for a certain event. The enableEvents

Explain the different sub-functions of Process Scheduling. Process scheduling contains the subsequent sub-functions: 1. Scheduling: Chooses the process to be executed next

What is the difference between a constant and variable? Explain with example.  A C constant is usually just the written version of a number. For example 1, 0, 5.73, 12.5e9. We

Appropriate Problems for ANN learning: Conversely as we did for decision trees there it's important to know where ANNs are the right representation scheme for such job. Howeve

Explain CSMsgInterface() Function with Predefined Protocol  A REQUEST structure is created for each message sent to the server. Messages passed to CSMsgInterface() as *dataMSG

Q. Explain about Control Memory Organization? One of the simplest ways to organize control memory is to organize micro-instructions for different sub cycles of machine instruct

Define external layer? The external layer is the plane at which the user sees and interacts with the data, that is, the data format in the user interface.  This data format is

Explain analysis and synthesis phase of a compiler. The synthesis and analysis phases of a compiler are: Analysis Phase: In this breaks the source program in constituent

explain about relations

Explain the Structure of a C Program? Each C program consists of one or more functions one of the which must be main(). A function name is forever followed by a pair of parenth