Unformatted Input and Output Functions, C language Assignment Help

Assignment Help: >> Introduction to C language >> Unformatted Input and Output Functions, C language

Unformatted Console Input/ Output Functions

 The unformatted console functions do not require any format conversion specification. Basically these functions are used for characters and strings input and output.

The getch( ): It just inputs a character without displaying it on the screen and without enter key pressed.

The getche( ): It inputs a character with displaying (echo) it on the screen and without enter key pressed.

The getchar( ): it also inputs a character with displaying it on the screen and also requires the enter key to be pressed following the character that we have typed.

The putch( ) and putchar( ): they print a character on the screen. As for as the working of putch( ) and putchar( ) is considered it's exactly same.

void main( )

{

                char x,y,z;

                printf("\nEnter three separate characters:");

                x=getch( );

                y=getche( );

                z=getchar( );

                putchar('\n');

                putch(x);

                putchar('\n');

                putchar(y);

                putchar('\n');

                putch(z);

}

Note: The limitations of putch ( ) and putchar ( ) is that they can output only one character at a time.

 

The gets ( ) and puts ( ):

We have used the scanf ( ) to receive a string, but it has a limitation that is we cannot input a multiword string using scanf ( ). As we press spacebar to tab the scanf ( ) assumes that the string being entered has ended and it places the null to terminate the input string. Inputting a string using gets ( ) solve this problem. It terminates the string when user presses the enter key. Thus spaces and tabs are perfectly acceptable as part of the input string.  The puts( ) function is the counter part of the gets( ) and works exactly opposite to gets( ). It outputs a string to the screen. Unlike printf( ) the puts can output only one string at a time. Similarly unlike scanf( ) the gets( ) can be used to read only one string at a time.

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