Reversing input characters The given code reverses an array of input characters.

The additional while loop in reverse() function is unnecessary I guess.
Any other method or way to remove it?

I would prefer to keep reverse() as void.

#include &lt;stdio.h&gt;

#define MAXLEN 65535 /* maximum length of input line */

void reverse(char s[], int l);

/* reverses given input line */

void main()
{
    int i, c;
    char line[MAXLEN];

    i = 0;

    while(i &lt; MAXLEN-1 &amp;&amp; (c = getchar()) != EOF &amp;&amp; c != '\n')  /* input characters in array */
    {
        line[i] = c;
        ++i;
    }

    reverse(line, i);
    printf("%s", line);
}

void reverse(char s[], int l)
{
    char rev[MAXLEN];
    int i, len;

    i = 0;
    len = l;    /* duplicate length of initial array */

    if(s[l] == '\0')
    {
        --l;
    }

    while(i &lt; len)
    {
        rev[i] = s[l];  /* reversing */
        ++i;
        --l;
    }

    i = 0;

    while (i &lt; len) /* what i think is unnecessary */
    {
        s[i] = rev[i];  /* storing back to initial array */
        ++i;
    }
}
Standard C requires that main() return int:

int main(void)


There's no need (for 20 years now) to write all local declarations before the code.  Introduce variables as you need them, so they can be initialised immediately:

{
    char line[MAXLEN];

    int i = 0;


There's no need for the extra storage rev in reverse().  We can reverse the string in place, by swapping first and last characters, then the second and second-last, and so on.

Use the Standard Library - it provides functions such as scanf(), getline(), strcpy() and strlen().  Don't write your own code to do these things - it makes your code much less clear, and causes readers to wonder what's being done that's different to the standard.