Home

A program to read a STRING and print it

C Programming Language 065

The following code shows how to write a program to read a STRING and print it.

Program

#include <stdio.h>

void main()
{
    char str[30];

    printf("Enter a string: ");
    gets(str);

    printf("str = %s", str);

    printf("\n");
}

Result

Enter a string: hello world
str = hello world


Last Updated on

Next Post: GraphProtocol: TS2322 null assignment in Subgraph →

Comments