Encoders
Hub for Computer Whizzes Register to join us

Encoders > More... > C > Program

/* Program that converts upper case to lower or lower case to
   upper, depending on the name it is invoked with. */

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

main(int argc, char *argv[])
{
	int c;
        if(strcmp(argv[0],"lower")==0)
		while((c=getchar())!=EOF)
			putchar(tolower(c));
	else
		while((c=getchar())!=EOF)
			putchar(toupper(c));
}