Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is difference between getchar,putchar functions and
printf and scanf function? does putchar show output only
when input given to it

Answer Posted / mudra

The standard C library provides several functions and macros for character 1/0. Here we consider the getchar and putchar macros. As these macros read or write a single character, they are typically used in a loop to read/write a sequence of characters.



A macro call is similar to a function call. Thus, it consists of a macro name followed by a comma-separated argument list enclosed in a pair of parentheses. If a macro does not require any arguments, the pair of parentheses must still be used.

The getchar macro is used to read a single character from the standard input stream, i. e., the keyboard. A call to get char takes the following form: getchar (). This macro waits until a key is pressed and then returns its value (after converting to integer). The value returned can be assigned to a variable of type char. However, note that this macro actually reads the data from the input buffer which is processed by program only when the Enter key is pressed. Thus, getchar does not return a value until the user presses the Enter key. As a result, it is not suitable for interactive programs. We can instead use the getch and getche functions which directly read the data from the keyboard.

The putchar macro is used to write a single character on the standard output stream (i.e., display). A call to this macro takes the following form: putchar (c), where c is an integer expression representing the character being written. Although this macro expects an argument of type int, we usually pass a character to it. The argument value (c) is converted to unsigned char and written to the standard output stream.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Who is the main contributor in designing the c language after dennis ritchie?

967


plz let me know how to become a telecom protocol tester. thank you.

2163


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

2090


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1789


What does a pointer variable always consist of?

1057


What is the difference between #include

and #include “header file”?

997


Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

1237


hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..

1882


What is the heap?

1177


What is the difference between a string and an array?

1174


How can you find the exact size of a data type in c?

974


What is variable and explain rules to declare variable in c?

1038


What is static identifier?

1188


Why isn't it being handled properly?

1023


What is ambagious result in C? explain with an example.

2568