what is full defination of getch , getchar , getche ,printf ,scanf,getchar, in c language
getch() returns the character you typed without displaying it on the screen.
getchar() works similarly and displays the character that you typed on the screen after "enter" is given.
getche() returns the character you typed by displaying(echoing) it on the screen.
The printf function prints output to stdout, according to format and other arguments passed to printf. The string format consists of two types of items: characters that will be printed to the screen, and format commands that define how the other arguments to printf are displayed.
In simple words printf function prints formatted output to a file.
scanf() function reads input from stdin, according to the given format, and stores the data in the other arguments. It works a lot like printf().
1) getchar () function reads a single character from standard input. It takes no parameters and its returned value is the input character. In general, a reference to the getchar function is written as character
variable = getchar();
For example char c;
c= getchar () ;
The second line causes a single character to be entered from the standard input device and then assigned to c.If an end-of-file condition is encountered when reading a character with the getchar function, the value of the symbolic constant EOF will automatically be returned. This function can also be used to read multicharacter strings, by reading one character at a time within a multipass loop.
2) The getch() Function
The getch() function obtains the next character from the stream stdin. It provides unbuffered character input without echo. The getch() function isn”t part of the ANSI standard. This means that it might not be available on every system. Additionally, it might require that different header files be included. Generally, the prototype for getch() is in the header file CONIO.H, as follows:
Because it is unbuffered, getch() returns each character as soon as the key is pressed, without waiting for the user to press Enter. Because getch() doesn’t echo its input, the characters aren”t displayed on-screen. The following function uses getch(), which is not ANSI-compliant. There is no guarantee that all compilers support non-ANSI functions.
3)scanf():-Input data can be entered into the computer from a standard input device by means of C library function scanf. This function can be used to enter any combination of numerical values, characters single character and strings. The function returns the number of data items that have been entered successfully.
In general terms, the scanf function is written as
scanf (string, parameter 1, parameter 2…, parameter n);
Where string= string containing certain required formatting information, and Parameter 1, parameter 2.. = parameters that represent the individual input data item. The control string or string comprises individual groups of characters, with one character group for each input data item. Each character
group must start with percent sign (%). In the string, multiple character groups can be contiguous, or separated by white space characters. The conversion character that is used with % sign are many in number and all have different meaning corresponding to type of data item that is to be input from keyboard.
4)printf():-A printf() format string specifies how the output is formatted. Here are the three possible components of a format string:
• Literal text is displayed exactly as entered in the format string. In the preceding example, the characters starting with the T (in The) and up to, but not including, the % comprise a literal string.
• An escape sequence provides special formatting control. An escape sequence consists of a backslash (\) followed by a single character. In the preceding example, \n is an escape sequence. It is called the new line character, and it means "move to the start of the next line." Escape sequences are also used to print certain characters
• A conversion specifier consists of the percent sign (%) followed by a single character. In the example, the conversion specifier is %d. A conversion specifier tells printf() how to interpret the variable(s) being printed. The %d tells printf() to interpret the variable x as a signed decimal integer
Copyright © 2020 HubPages Inc. and respective owners. Other product and company names shown may be trademarks of their respective owners. HubPages® is a registered Service Mark of HubPages, Inc. HubPages and Hubbers (authors) may earn revenue on this page based on affiliate relationships and advertisements with partners including Amazon, Google, and others.
HubPages Inc, a part of Maven Inc.
|HubPages Device ID||This is used to identify particular browsers or devices when the access the service, and is used for security reasons.|
|Login||This is necessary to sign in to the HubPages Service.|
|HubPages Traffic Pixel||This is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.|
|Remarketing Pixels||We may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.|
|Conversion Tracking Pixels||We may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.|