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/*from   ww w  .ja  va2s . c  om*/

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