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

How the canvas class and the graphics class are linked, A Canvas object giv...

A Canvas object gives access to a Graphics object by its paint() method.

Programming, Write a procedure for each of the following: (i) To find the m...

Write a procedure for each of the following: (i) To find the maximum MAX of the values in the list. (ii) To find the average MEAN of the values in the list. (iii) To find the produ

Define cpu scheduling, Define CPU scheduling. CPU scheduling is the met...

Define CPU scheduling. CPU scheduling is the method of switching the CPU among various processes. CPU scheduling is the basis of multiprogrammed operating systems. By switching

Computer graphics, What is intractive graphics and user dialouge in comput...

What is intractive graphics and user dialouge in computer graphics

What is the role of a controller in an mvc application, The controller resp...

The controller responds to user interactions, with the application, by selecting the act method to implement and also selecting the view to render.

Purpose of pointer phrase in string command, The Purpose of POINTER phrase ...

The Purpose of POINTER phrase is to verify the leftmost position within receiving field where the first transferred character will be kept

What is a compiler, What is a compiler? A Compiler is a program that ac...

What is a compiler? A Compiler is a program that accepts a program written in a high level language and creates an object program.

Return a string, Write a function that will prompt the user individually fo...

Write a function that will prompt the user individually for a filename and extension and will make and return a string with the form 'filename.ext'.

Design a multiplier, how can we design a multiplier by using ASM chart and ...

how can we design a multiplier by using ASM chart and then design the data controller ?!!

What is bus arbitration, What is bus arbitration? It is method by which...

What is bus arbitration? It is method by which the next device to become the bus master is selected and bus mastership is transferred to it. There are two ways for doing this:

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