Home

A program to read a string and print it using gets and puts

C Programming Language 070

The following code shows how to write a program to read a string and print it using gets() and puts().

Program

#include <stdio.h>

void main()
{
    char str[20];

    printf("Enter string: ");
    gets(str);
    printf("String is: ");
    puts(str);

    printf("\n");
}

Result

Enter string: Hello world!!
String is: Hello world!!


Last Updated on

Next Post: GraphProtocol: TS2322 null assignment in Subgraph →

Comments