Program For Problem Solving Unit3
Program For Problem Solving Unit3
• 1. gets()
• 2. puts()
• 3. getchar()
• 4. putchar()
• 5. Printf()
Unit 3 – String Functions
• 1. gets()
• It is used to take a single input at a time but can be used to input a
complete sentence with spaces unlike scanf(). It stops reading character
when the newline character is read or end-of the file is reached.
• Declaration
• char *gets(char *str)
• str- This is the pointer to an array of characters where the C string is
stored.
• Return Value:
• This function returns str on success, and NULL on error or when end of
file occurs.
Unit 3 – String Functions
Unit 3 – String Functions
• 2. puts()
• This function writes strings or lines to stdout, i.e, the output stream. The string is
printed with newline and an integer value is returned.
• Declaration
• int puts(const char* string)
• Example:
# include<stdio.h>
void main(){
// Initializing the string.
char string[] = "SRM University";
// Writing our string to stdout.
puts(string);
}
Unit 3 – String Functions
• OUTPUT