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.
Prototype:
- int getch (void);
Usage:
getch reads a single character directly from the keyboard, without echoing to the screen.
(ii) strcmp ( )
- strcmp ( ) compare two strings.
Prototype:
- int strcmp (const char *s1, const char *s2);
Usage:
strcmp performs an unsigned comparison of s1 and s2.
(iii) getchar ( )
- getchar ( ) is a macro that gets a character from stdin.
Prototype:
- int getchar (void);
Usage:
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.
Prototype:
- char *gets (char *s);
Usage:
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).
Prototype:
- int *puts (const char *s);
Usage:
Puts copies the null-terminated string s to the standard output stream stdout andd appends a newline character.