about summary refs log tree commit diff
path: root/others/easy20160714/17.c
blob: edc8f1c832a1897db90c934ad29236b6bd58d4e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define _GNU_SOURCE
#include <ctype.h>
#include <stdio.h>

int main()
{
	FILE *fi = fopen("INP.TXT", "r"), *fo = fopen("OUT.TXT", "w");
	char c, prevc = 32;

	while ((c = fgetc(fi)) != EOF) {
		if (prevc ^ 32)
			fputc(isupper(c) ? c + 32 : c, fo);
		else if (c ^ 32)
			fputc(islower(c)) ? c - 32 : c, fo);
		prevc = c;
	}

	fcloseall();

	return 0;
}