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
Input-Output-Processor Interconnection Network (IOPIN) This interconnection network is used for communication between I/O channels and processors. All processors commune with a

Define Cloud services with example. Any web-based application or service offered by cloud computing is known as a cloud service. Cloud services can contain anything from calend

The main features of TCP are: Reliability: TCP makes sure that any data sent by a sender arrives at destination as it was sent. There can't be any data loss or change in the

Home Entertainment: E-commerce has led to HOME ENTERTAINMENT. The video aspect usually includes a large-screen and/or high definition television or a projection system.

Second Generation (1954-1962) The second generation saw various significant developments at every level of computer system design, from technology used to build the basic circu

Write a short notes on storage classes in C. Every variable and function in C has two attributes : type and storage class. The four storage classes are automatic, external, reg

Q. Explain Logical shifts with example? Logical shifts LOGICAL SHIFT LEFT and LOGICAL SHIFT RIGHT insert zeros to end bit position and other bits of a word are shifted left or

What is 1 00 line exchange with one two-motion selector per subscriber. Design: In, Strowger switching system is designed by using one two-motion selector for all subscrib

No, You cannot apply the link and Association interchangeably. Since link is used show the relationship among the two objects. But Association is used signify the relationship

The larger the Grade of Service, the worse is the service given, it is true or false. Ans: It is true that larger the Grade of Service, the worse service is provided.