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 is EDO RAM, What is EDO RAM A minor modification to the structure ...

What is EDO RAM A minor modification to the structure of the DRAM changes the device into an EDO (extended data output) DRAM device. In EDO memory, any memory access, including

What do you mean by rad, a. What are the activities included during the pro...

a. What are the activities included during the process of developing a formal specification of a sub-system interface? b. Explain the Pair Programming? What are the benefits of

What is data structure, What is data structure? A data structure is a w...

What is data structure? A data structure is a way of organizing data that considers not only the items kept, but also their relationship to each other. Advance knowledge abo

What is electronic data interchange, What is Electronic Data Interchange? ...

What is Electronic Data Interchange? Electronic Data Interchange (EDI): It is used by organizations for transactions which arise on regular basis to a pre-found format.

Identify specific weaknesses in the design, Identify three specific weaknes...

Identify three specific weaknesses in the design of the websites, derived from your analyses within Questions Part (c) and/or Question Part (a). There should be at least one weakne

What do you mean by work flow automation, What do you mean by work flow aut...

What do you mean by work flow automation? Work Flow Automation: Organizations frequently standardize processes across the association and encourage users to accept them. E

Object oriented systems analysis and design, Analysis and design form the b...

Analysis and design form the basis on any significant software artifact. Analysis is critical in terms of making sure that the final artifact actually meets user requirements (ie b

How do you make an append query, Append query can be used if you would like...

Append query can be used if you would like to add new rows of data to an already active table. The process of making an append query follows these steps they are. ? Basic step

Which method uses the greatest number of layers in OSI model, Which method ...

Which method uses the greatest number of layers in the OSI model? Gateway utilizes the greatest number of layers into the OSI model.

Performance analysis, In order to calculate the performance of the program,...

In order to calculate the performance of the program, the normal form of analysis of the program is to simply measure the total amount of CPU time needed to implement the various p

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