Convert c to lower case; ASCII only - C Data Type

C examples for Data Type:char

Description

Convert c to lower case; ASCII only

Demo Code

#include <stdio.h>

int lower(int c){
    if (c >= 'A' && c <= 'Z')
        return c + 'a' - 'A';
    else//from   w  ww  . ja  v  a 2s .c  o  m
        return c;
}

int main()
{
    int c;

    while ((c = getchar()) != EOF)
        putchar(lower(c));
    return 0;
}

Result


Related Tutorials