CodesJava

Easy learning with example program codes

C gets() & puts()


C gets() function:

C library facilitates a special function to read a string from a user. This function is represented as gets() function and is defined in the <stdio.h> header file of C.

C puts() function:

C library also facilitates a special function to print a string on the console screen. This function is represented as puts() function and is also defined in the <stdio.h> header file of C.

Example:

#include<stdio.h>  
#include <string.h>  
 
void main()
{    
char day[10];    
printf("Enter current week day: \n");    
gets(day);
 
printf("Today is: ");    
puts(day);  
}

Output

Enter current week day: THURSDAY
Today is: THURSDAY
Posted in C   
Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki