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

Assignment Help:

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.

 


Related Discussions:- How putchar function is used within a c program

What are the benefits of web-based spreadsheets, What are the Benefits of W...

What are the Benefits of Web-Based Spreadsheets? The spreadsheets can be accessed from any Internet-connected computer, not just the computer originally formed the spreadsh

Explain 100 line exchange with selector finder, Explain 100 line exchange w...

Explain 100 line exchange with selector finder. Design: In place of 100 two-motion selectors as in the case of Design 3, suppose we consider only 24 two-motion selectors. Whe

Array to be sorted is partitioned again and again, The sorting method where...

The sorting method where array to be sorted is partitioned again and again in such a way that all elements less than or equivalent to partitioning element appear before it and thos

C-programing, c-program for the minimum total number of shelves

c-program for the minimum total number of shelves

What is the functionality of remote login, What is the functionality of Rem...

What is the functionality of Remote Login? Remote Login gives similar functionality of telnet, along with the added functionality of not involving a password from trusted cli

Explain difference between macro call and macro expansion, Explain differen...

Explain difference between macro call and macro expansion. Macro expansion: While a macro name is used along with a set of actual parameters this is replaced through a code g

Sem 4, Which are the subject of sem 4?

Which are the subject of sem 4?

Explain characteristics of latch and flip-flop, Explain characteristics of ...

Explain characteristics of Latch and Flip-Flop. Latches are level-sensitive and transparent While the clock is high it passes input value to Output While the clock is l

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd