Input & Output Functions :
Input and output functions are used in the c language for getting values and showing values from the terminal.
If we want to accept differently input values we can use input functions in the c language. Same we consider the output function to show values in the terminal.
Output Functions
//* gets():
The gets() function is used to read a line of text from the console, including spaces until the Enter key is pressed.
it is considered unsafe and should be avoided because it does not check the length of the input, which can lead to buffer overflow.
It is recommended to use fgets() instead.
//* What is buffer overflow:
Buffer overflow is a vulnerability that occurs when a program writes data beyond the allocated boundaries of a buffer, causing the extra data to overwrite adjacent memory locations.
In C programming, where manual memory management is common, a buffer overflow can lead to serious security risks and unintended behavior.
//* getchar() :
The getchar() function is used to read a single character from the console or input stream.
It waits for the user to enter a character and returns its ASCII value as an integer.
//* getch():
The getch() function is a non-standard function available in some C compilers, primarily on Windows.
It reads a single character from the console without echoing it on the screen and immediately returns the character.
Input Functions
scanf()
puts()
putchar()
//* puts():
The puts() function is used to display a string (a sequence of characters) on the console. It automatically adds a new line character at the end of the string.
//* putchar():
The putchar() function is used to display a single character on the console.
It takes a character as an argument and returns the character as an unsigned char.
Post a Comment