What is puts() Function?
The word "puts" is the short of put string. The puts() function is used to display string on the computer screen. The new line is automatically inserted after displaying the string.The general syntax to call puts() function is as follows:
puts (string);
In the above syntax:string
It represents the string to be displayed on the screen. It may be a string variable or string constant. In case of string constant, the string is enclosed in double quotation marks.The following statement will display "welcome" on screen using puts() function:
puts ("welcome");
This statement is equivalent to:cout
Also read about gets() function to clear the following example program of puts() function.
#include
#include
main()
{
char st[35];
clrscr();
puts ("Enter a string:");
gets (st);
puts ("The string is: ");
puts (st);
getch();
}
Also read about gets() function to clear the following example program of puts() function.
Example of puts() function
This program code inputs a string using gets() function and displays it on screen using puts() function.#include
#include
main()
{
char st[35];
clrscr();
puts ("Enter a string:");
gets (st);
puts ("The string is: ");
puts (st);
getch();
}