Explain the meaning and usage of each of the following function prototypes: 5×2=10m
(i) getch ( ) (ii) strcmp ( ) (iii) getchar ( ) (iv) gets ( ) (v) puts ( )
(i) getch ( )
- getch ( ) gets a character from console but does not echo to the screen.
- int getch (void);
getch reads a single character directly from the keyboard, without echoing to the screen.
(ii) strcmp ( )
- strcmp ( ) compare two strings.
- int strcmp (const char *s1, const char *s2);
strcmp performs an unsigned comparison of s1 and s2.
(iii) getchar ( )
- getchar ( ) is a macro that gets a character from stdin.
- int getchar (void);
getchar is a macro defined as getc(stdin) getchar returns the next character on the input stream stdin.
(iv) gets ( )
- gets ( ) gets a string from stdin.
- char *gets (char *s);
gets collects a string of characters terminated by a new line from the standard input stream stdin and puts it into s.
(v) puts ( )
- puts ( ) outputs a string to stdout (and appends a newline character).
- int *puts (const char *s);
Puts copies the null-terminated string s to the standard output stream stdout andd appends a newline character.