Program to take string as input from user in C

Write a Program to take a string as input from the user in C.

C Program

#include <stdio.h>
#include <string.h>

int main()
{
    char str[1000];

    printf("Enter a string : ");
    fgets(strsizeof(str), stdin);

    printf("String is %s "str);

    return 0;
}

Example:

Enter a string : Hello World

Example:

String is Hello World
 


No comments:

Post a Comment