C - Write program to define constant for array length

Requirements

Change the array size to a constant value.

Set the constant to allow only 30 characters input.

Hint

use #define to create constant

Demo

#include <stdio.h>

#define INPUT_SIZE 30/* w  ww.j a v a  2  s  . c o  m*/

int main()
{
    char name[INPUT_SIZE];

    printf("Who are you? ");
    fgets(name,INPUT_SIZE,stdin);
    printf("Glad to meet you, %s.\n",name);
    return(0);
}

Result

Related Exercise